RedirectToAction没有结束响应参数。导致抛出'线程被中止'的例外

时间:2022-06-02 00:14:02

I am working on MVC4 web application.

我正在研究MVC4 Web应用程序。

The current method RedirectToAction doesn't have an optional parameter to specify whether or not to end the response, whereas the Response.Redirect method does. Without setting the endResponse parameter to false (it is true by default), the thread gets aborted. This means every time I call RedirectToAction, I end up with a "Thread was being aborted" message in the event log. This is explained here https://support.microsoft.com/en-us/kb/312629

当前方法RedirectToAction没有可选参数来指定是否结束响应,而Response.Redirect方法则指定。如果不将endResponse参数设置为false(默认情况下为true),则线程将中止。这意味着每次调用RedirectToAction时,我最终都会在事件日志中显示“Thread was aborted”消息。这在这里解释https://support.microsoft.com/en-us/kb/312629

how to get workaround for this issue?

如何解决此问题?

1 个解决方案

#1


0  

I think i have got fix for this. before this i have some recommendations when you have long running process

我想我已经解决了这个问题。在此之前我有一些建议,当你有长时间运行的过程

1) Use Fix mentioned in https://support.microsoft.com/en-us/kb/312629

1)使用https://support.microsoft.com/en-us/kb/312629中提到的修复程序

2) Try to move long running code out of IIS, try to use service which will run in background.

2)尝试将长时间运行的代码移出IIS,尝试使用将在后台运行的服务。

For those who cant change existing code here is quick and dirty solution.

对于那些无法改变现有代码的人来说,这是快速而肮脏的解决方案

Increase idle time out in IIS (app pool of your application => right click=>advanced setting ) in minutes to whatever you think enough to complete the long running process.

在几分钟内将IIS中的空闲时间(应用程序的应用程序池=>右键单击=>高级设置)增加到您认为足以完成长时间运行的过程。

#1


0  

I think i have got fix for this. before this i have some recommendations when you have long running process

我想我已经解决了这个问题。在此之前我有一些建议,当你有长时间运行的过程

1) Use Fix mentioned in https://support.microsoft.com/en-us/kb/312629

1)使用https://support.microsoft.com/en-us/kb/312629中提到的修复程序

2) Try to move long running code out of IIS, try to use service which will run in background.

2)尝试将长时间运行的代码移出IIS,尝试使用将在后台运行的服务。

For those who cant change existing code here is quick and dirty solution.

对于那些无法改变现有代码的人来说,这是快速而肮脏的解决方案

Increase idle time out in IIS (app pool of your application => right click=>advanced setting ) in minutes to whatever you think enough to complete the long running process.

在几分钟内将IIS中的空闲时间(应用程序的应用程序池=>右键单击=>高级设置)增加到您认为足以完成长时间运行的过程。