...">

ExecuteTimeout not working on asp.net mvc

I tried setting executeTimeout in web.config for asp.net mvc application.

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

code>

any operation used Thread.sleep in Index

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

Also, I set the debugger debugging to false . after the sleep is about 30 seconds and the exception "request timeout" is not thrown, and the view was successfully displayed.

Does anyone know how to make executeTimeout work in asp.net mvc?

+7
asp.net-mvc
source share
2 answers

You need to do the following:

  • The domain name is not localhost (to check the timeout you should use "YourComputerName" instead of "localhost").
  • The project is compiled in Release mode.
  • <compilation debug="false">

Then think about it:

Internally, ASP.NET uses a timer to invoke the request cancellation process. This timer starts once every 15 seconds, so if the executionTimeout parameter is set to 3 seconds, in fact, the request can be disconnected at any time from 3 seconds to 18 seconds.

When the timer is started, the thread from ThreadPool is used to check all requests. Those that time out are ThreadAbortException a ThreadAbortException , causing Abort in the thread executing the request.

Note. Keep in mind that ThreadAbortException can only be observed by managed code. Therefore, if a thread is called by some unmanaged functions, the thread will not be interrupted, and therefore the timeout will not be applied until execution returns to the managed world. This can be an arbitrary delay length, depending on what the unmanaged code does.

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

+4
source share

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

+1
source share

All Articles