In some cases it can take quite some time for the web server to complete your webpage. Setting a time out is not that difficult but Googling around you will either find over complicated scenarios or a very simple and clear story in Dutch. Before recapitulating that one in English I have to credit the author Michiel van Otegem. Besides writing some good content he's done a lot of work for the Dutch user group dotned. See him smiling here, he's the guy on the final picture.
The timeout for a page request depends whether you are running debug or release code. The setting is in the web.config. In debug mode the timeout is 30000000 seconds which is about a year. In release mode the timeout is only 90 seconds. In some cases that may not be enough. You cannot set the timeout as a property of the page itself; it is a property of the global Server object. Set it in the page init event and reset it in the page unload event.
private int timeOut;
private void KopierenJaar_Init(object sender, System.EventArgs e)
{
timeOut = Server.ScriptTimeout;
// Give it 1 hour = 3600 seconds
Server.ScriptTimeout = 3600;
}
private void KopierenJaar_Unload(object sender, System.EventArgs e)
{
Server.ScriptTimeout = timeOut;
}
In case your page is doing heavy things in the database you have to set db timeouts as well. See here for a quick look at that.
Posted
Thu, Jun 15 2006 8:31 AM
by
pvanooijen