|
Setting and Extending Script and Page Timeouts (ASP.Net) |
|
|
Written by: Evan Cummings
Setting and Extending Script and Page TimeoutsLong running processes are typically negligible issues for a typical desktop or server application. What happens, however, when we switch from a fully stately environment to that of the web? Page and script timeouts will easily kill your session with a big 'operation has timed out' message - clearly what we are trying to avoid when we are attempting to provide a smooth and seamless user experience! The good news is that we have several tools to approach this problem so we can accomadate for situations like these that are simply unavoidable.
Approach #1 -The Page Level
On the page level, we have access to the Server object, which will allow us to manipulate common functionalities. In order to change the script timeout for a long running process, we can simply say:
Server.ScriptTimeout = 600
For this example, we are setting the ScriptTimeout property of the Server object to 600 seconds (the property accepts values only in seconds).
Approach #2 - The Web.config
For a more flexible approach, we can stay out of the code all together and work within the Web.config configuration file:
<system.web> <httpRuntime executionTimeout="600" /> </system.web>
We simply add a new entry to the <system.web> node, <httpRuntime />, and set its executionTimeout property to 600, just like the Server object setting from above.
Approach #3 - IIS
If you have access to it, IIS Manager can be another source to help extend the life of long running processes on your website. Browse to IIS Manager, drill down to your website you wish to modify, right click and select properties. From the Directory tab, select Configuration under the Application Settings sub heading. This will bring up another dialog box in which we want to browse to the Options tab. On this dialog, we can modify our ASP script timeout (which has a default of 90 seconds). It is also worth noting that we can also change the session timeout as well from IIS.
A Final Point
The mode your project is deployed in has a direct impact on page timeouts. Release mode compiles and deploys with the default 90 second page timeout in mind - however debug mode is another story. Debug mode deployments have a timeout set close to a year is length (30000000 seconds). It is important to take this into consideration as you build and deploy your applications.
Content - IIS, Page time out, script timeout, asp.net |
|
|
|
|
|