BeanSoftware Logo

ASP.NET Database Search Control

    Write For Us

How To Change Script Timeout In ASP.NET?

Default value of execution time on server is 90 seconds. If some ASP.NET page needs more time than 90 seconds, script timeout error will be returned. In most cases, this error occurs because of some bug in code, like endless loop or not optimized SQL query to database that needs too much time to execute. First solution is always to try to optimize code to execute faster. But, if your code must take longer time to execute then you can increase script timeout value on server.

Simple way to increase script timeout in ASP.NET is using of Server.ScriptTimeout property and set new value in seconds. Let say you need to increase execution time to 10 minutes, code would be:

[ C# ]

Server.ScriptTimeout = 600;

[ VB.NET ]

Server.ScriptTimeout = 600

Second way is to configure script timeout in web.config using executionTimeout parameter of httpRuntime node.

   <httpRuntime executionTimeout="600" />

Why my script still returns an error after I increased script timeout?

Server.ScriptTimeout property or executionTimeout parameter in web.config are ignored if debug="true". To activate script timeout custom value, in web.config set configuration like this:

   <httpRuntime executionTimeout="600" />
compilation debug="true">

Why my script timeout delay few seconds longer than I wanted?

Default value of script timeout is 90 seconds. If you increase this value, timeout will probably work well. Zero value means that script has unlimited timeout. But, if timeout value is very short it is possible to experience delays.

What if ASP.NET script timeout is not enough?

It is always possible to have a bug somewhere that could crash your code and cause script timeout error. To achieve better user experience, you can make custom error page that will inform user and write error information to some log file, so you will be informed and eventually solve the problem. More about custom error pages you can read at Custom Error Pages In ASP.NET tutorial.

Related articles:

1. ASP.NET Configuration System

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback

Copyright © 2002-2008 Bean Software. All rights reserved.