Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

executionTimeout not working on asp.net mvc

Tags:

asp.net-mvc

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?

like image 248
user192415 Avatar asked Oct 23 '10 03:10

user192415


People also ask

What is the default httpRuntime ExecutionTimeout?

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.

What is render view in MVC?

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.

How to remove server Header in ASP.NET MVC?

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.

What is httpRuntime in Web config?

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.


1 Answers

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/

like image 106
Jani Hyytiäinen Avatar answered Oct 12 '22 11:10

Jani Hyytiäinen