executionTimeout不适用于asp.net mvc

时间:2022-06-07 04:07:13

I tried set the executionTimeout in web.config for an asp.net mvc application.

我尝试在web.config中为asp.net mvc应用程序设置executionTimeout。

<location path="Home/Index">
    <system.web>
      <httpRuntime  executionTimeout="5"/>
    </system.web>
  </location>

any used the Thread.sleep in Index action

任何在Index动作中使用Thread.sleep

public ActionResult Index()
        {
            Thread.Sleep(30000);            
            return View();
        }

also, i set complilation's debug to "false". after the action sleep about 30 seconds and the "request timeout" exception not throws out and the view had been rendered successfully.

另外,我将complilation的调试设置为“false”。在操作休眠约30秒后,“请求超时”异常不会抛出并且视图已成功呈现。

any one know how to make the executionTimeout to work in asp.net mvc?

任何人都知道如何使executionTimeout在asp.net mvc中工作?

2 个解决方案

#1


4  

You need to fulfill the following:

您需要满足以下条件:

  1. Domain name is not localhost (to test timeout you should use "YourComputerName" instead of "localhost").
  2. 域名不是localhost(要测试超时,您应该使用“YourComputerName”而不是“localhost”)。
  3. Project is compiled in Release mode.
  4. 项目在发布模式下编译。
  5. <compilation debug="false">

Then also, think about this:

然后,想一想:

Internally ASP.NET uses a Timer to invoke the request cancelation process. This timer is fired once every 15 seconds, so if the executionTimeout is set to 3 seconds, in reality the request can timeout at any time between 3 seconds and 18 seconds.

ASP.NET内部使用Timer来调用请求取消过程。此计时器每15秒触发一次,因此如果executionTimeout设置为3秒,实际上请求可以在3秒到18秒之间的任何时间超时。

When the timer is fired, a thread from the ThreadPool is used to check all the requests. The ones that have timed out are sent a ThreadAbortException by calling Abort on the thread executing the request.

当计时器被触发时,ThreadPool中的一个线程用于检查所有请求。已经超时的那些通过在执行请求的线程上调用Abort来发送ThreadAbortException。

Note: Keep in mind that ThreadAbortException can only be observed by managed code. So if you thread is calling some unmanaged functions, the thread will not be aborted, and therefore the timeout will not be enforced, until the execution returns to the managed world. That can be an arbitrary length of delay depending on what those unmanaged code does.

注意:请记住,只有托管代码才能观察到ThreadAbortException。因此,如果线程正在调用某些非托管函数,则线程不会被中止,因此在执行返回托管世界之前不会强制执行超时。这可以是任意长度的延迟,具体取决于那些非托管代码的作用。

Read more: http://consultantpoint.wordpress.com/2012/09/07/how-the-execution-timeout-is-managed-in-asp-net/

阅读更多:http://consultantpoint.wordpress.com/2012/09/07/how-the-execution-timeout-is-managed-in-asp-net/

#2


1  

If you have your web.config set to debug="true" it will ignore the value you set: http://msdn.microsoft.com/en-us/library/e1f13641.aspx

如果您将web.config设置为debug =“true”,它将忽略您设置的值:http://msdn.microsoft.com/en-us/library/e1f13641.aspx

#1


4  

You need to fulfill the following:

您需要满足以下条件:

  1. Domain name is not localhost (to test timeout you should use "YourComputerName" instead of "localhost").
  2. 域名不是localhost(要测试超时,您应该使用“YourComputerName”而不是“localhost”)。
  3. Project is compiled in Release mode.
  4. 项目在发布模式下编译。
  5. <compilation debug="false">

Then also, think about this:

然后,想一想:

Internally ASP.NET uses a Timer to invoke the request cancelation process. This timer is fired once every 15 seconds, so if the executionTimeout is set to 3 seconds, in reality the request can timeout at any time between 3 seconds and 18 seconds.

ASP.NET内部使用Timer来调用请求取消过程。此计时器每15秒触发一次,因此如果executionTimeout设置为3秒,实际上请求可以在3秒到18秒之间的任何时间超时。

When the timer is fired, a thread from the ThreadPool is used to check all the requests. The ones that have timed out are sent a ThreadAbortException by calling Abort on the thread executing the request.

当计时器被触发时,ThreadPool中的一个线程用于检查所有请求。已经超时的那些通过在执行请求的线程上调用Abort来发送ThreadAbortException。

Note: Keep in mind that ThreadAbortException can only be observed by managed code. So if you thread is calling some unmanaged functions, the thread will not be aborted, and therefore the timeout will not be enforced, until the execution returns to the managed world. That can be an arbitrary length of delay depending on what those unmanaged code does.

注意:请记住,只有托管代码才能观察到ThreadAbortException。因此,如果线程正在调用某些非托管函数,则线程不会被中止,因此在执行返回托管世界之前不会强制执行超时。这可以是任意长度的延迟,具体取决于那些非托管代码的作用。

Read more: http://consultantpoint.wordpress.com/2012/09/07/how-the-execution-timeout-is-managed-in-asp-net/

阅读更多:http://consultantpoint.wordpress.com/2012/09/07/how-the-execution-timeout-is-managed-in-asp-net/

#2


1  

If you have your web.config set to debug="true" it will ignore the value you set: http://msdn.microsoft.com/en-us/library/e1f13641.aspx

如果您将web.config设置为debug =“true”,它将忽略您设置的值:http://msdn.microsoft.com/en-us/library/e1f13641.aspx