Server.ScriptTimeout sets global scale?

Throughout my experience, both in classic ASP and in ASP.NET, I always understood that the calls to set the value of Server.ScriptTimeout were local to the scope for the current request. In other words, calling Server.ScriptTimeout = 600 would set the processing time for the current request to 10 minutes. Subsequent or even parallel requests to other resources will use the default setting for Server.ScriptTimeout .

Recently, in a code review, I was informed that when installing Server.ScriptTimeout value sets the processing time for each page of the site until the application pool is reused. The proposed β€œfix” was approximately as follows:

 public class MyPage : Page { private const int desiredTimeout = 600; private int cachedTimeout; private void Page_Load(object sender, EventArgs e) { // cache the current timeout in a private store. cachedTimeout = Server.ScriptTimeout; Server.ScriptTimeout = desiredTimeout; } private void Page_Unload(object sender, EventArgs e) { // restore the previous setting for the timeout Server.ScriptTimeout = cachedTimeout; } } 

This seems strange to me, because the developer calling Server.ScriptTimeout = 1 on the page can hit the site, since every other page will be allowed only for one second. In addition, this behavior will affect any current requests that may occur between the current Page_Load and Page_Unload events, which look like a concurrency nightmare.

To be thorough, I made a two-page test posting - Page 1 , which sets Server.ScriptTimeout to some really high number and Page 2 , which simply displays the current value for Server.ScriptTimeout . No matter what value I set to Page 1 , Page 2 always shows the default value. So my test shows that Server.ScriptTimeout is local in scope.

I noticed that if my web.config has debug = "true", Server.ScriptTimeout has no effect - and MSDN states this explicitly on its page. In this mode, all calls to read the values ​​for Server.ScriptTimeout return an absurdly large number, regardless of what I set it to.

So my question is to be absolutely sure that I'm not missing something, does the instance setting the value for Server.ScriptTimeout affect the processing time of the entire site (global in scope) or my belief Is the effect local to the current context only? I googled this question to no avail, and MSDN seems to be silent on this issue.

Any links and / or experiences - one way or another - we will be very grateful! The documentation covering this seems inadequate, and I would appreciate any authoritative information.

+7
source share
1 answer

It is really specific to the request:

 public int ScriptTimeout { get { if (this._context != null) { return Convert.ToInt32(this._context.Timeout.TotalSeconds, CultureInfo.InvariantCulture); } return 110; } [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Medium)] set { if (this._context == null) { throw new HttpException(SR.GetString("Server_not_available")); } if (value <= 0) { throw new ArgumentOutOfRangeException("value"); } this._context.Timeout = new TimeSpan(0, 0, value); } } 

where _context HttpContext

+9
source

All Articles