Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between executionTimeout and Server.ScriptTimeout

Tags:

I have an aspx page which contains code that is liable to take 5 minutes or more to execute on the server. So I need to extend the amount of time before the Request times out.

What is the difference between putting this in the web.config for the site:

<location path="~/MyPage.aspx">     <system.web>       <httpRuntime executionTimeout="600"/>           </system.web>       </location> 

and putting this in the code behind on the page:

protected void Page_Load(object sender, EventArgs e) { Page.Server.ScriptTimeout = 600; } 
like image 662
Martin Smellworse Avatar asked Jan 03 '14 10:01

Martin Smellworse


People also ask

What is Server ScriptTimeout?

The ScriptTimeout property specifies the maximum amount of time that a script can run before it is terminated. The timeout will not take effect while a server component is processing.

What is executionTimeout for 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.


2 Answers

As for the executionTimeout setting for ASP.NET's <httpRuntime> configuration not work problem. The documentation on this attribute is really not very clear. The problem is caused by the following reasons:

  1. This setting will take effect only when we set the "debug" to false in web.config , like:

when set to "debug=true" mode, the runtime will ignore the timeout setting.

  1. Even we set the debug="false", the executionTimeout will still has some delay when the value is very small. In fact, it is recommeded that we don't set the timeout less than 1.5 minutes. And when we set the timeout to less than 1 minute, the delay will span from 5 secs up to 15 secs. For example, if we set executionTimeout="5", it may take a bout 15 seconds for the page to timeout.

Server.ScriptTimeout property is a COM interface which is used in classic ASP. The executionTimeout of ASP.NET is the replacement of ScriptTimeout in asp.net , so we no longer need to use ScriptTimeout in asp.net.

In addition, as for have the script ALWAYS terminate after 2 seconds

I'm afraid there is no means in asp.net's runtime setting since the asp.net's runtime request processing management can't reach this level of accuracy, 2 seconds is a too small value which may make the performance very pool to monitor such a small interval. If we do need to let a certain processing timeout, we can consider put the timeout logic in the above application code level. For example, if we're executing SqlCommand , we can set the sqlcommand 's execution timeout. Or if we are executing a async call in page code, we can set a timeout for the async call

Hope helps.

like image 91
Amarnath Balasubramanian Avatar answered Sep 20 '22 22:09

Amarnath Balasubramanian


From this page, some official info: https://msdn.microsoft.com/en-us/library/system.web.httpserverutility.scripttimeout%28v=vs.110%29.aspx

The ScriptTimeout property can be set in the Web.config file by setting the executionTimeout attribute of the element. Setting the time-out programmatically with the ScriptTimeout property takes precedence over the Web.config setting.

I just thought it might be beneficial to note that Microsoft says "executionTimeout" is the same property as "ScriptTimeout".

like image 27
FirstFraktal Avatar answered Sep 20 '22 22:09

FirstFraktal