I tried set the executionTimeout in web.config 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?
The executionTimeout attribute of <httpRuntime> defines the maximum amount of time in seconds that a request is allowed to run before it is automatically terminated by ASP.NET. The default value is 90 seconds.
A view renders the appropriate UI by using the data that is passed to it from the controller. This data is passed to a view from a controller action method by using the View method. Note. The Views folder is the recommended location for views in the MVC Web project structure.
Removing X-AspNet-Version Header Open the Web. Config file, find the node <httpRuntime> under <system. web> add the enableVersionHeader attribute to httpRuntime node and set it to false.
The HttpRuntimeSection allows you to handle those parameters that affect the behavior of the ASP.NET runtime. It refers to the node in the configuration file that is indicated by the <httpRuntime> element and can be used at any level in the configuration hierarchy.
You need to fulfill the following:
<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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With