开发者

executionTimeout not working on asp.net mvc

I tried set the executionTimeout in web.co开发者_运维知识库nfig for an asp.net mvc application.

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

any used the Thread.Sleep in Index action

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.

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


You need to fulfill the following:

  1. Domain name is not localhost (to test timeout you should use "YourComputerName" instead of "localhost").
  2. Project is compiled in Release mode.
  3. <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.

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.

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.

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜