tags:

views:

475

answers:

2

I have a page that takes a few minutes to run. When I set debug="false" in the <compilation /> tag in web.config, I get a "Request timed out." error (and internal try/catch blocks in my code get a "Thread was being aborted." error.

What is the fix to allow long pages to run in production mode? Does debug mode have an infinite timeout?

+4  A: 

You can set the max. duration for requests in web.config:

<system.web>
  ...
  <httpRuntime executionTimeout="600" />

Where executionTimeout specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. Details can be found here.

M4N
+3  A: 

You should just need to increase the script timeout for page executions. It defaults to 90 seconds, so if you need more time, change it in the following system.web element (executionTimeout attribute):

<httpRuntime executionTimeout="seconds"
             maxRequestLength="kbytes"
             minFreeThreads="numberOfThreads"
             minLocalRequestFreeThreads="numberOfThreads"
             appRequestQueueLimit="numberOfRequests" 
             useFullyQualifiedRedirectUrl="true|false"  />
jrista
In addition to increasing the timeout, you might also want to look into making the page asynchronous. A long running page in synchronous mode will consume a thread for the duration. By making it async, you free that ASP.NET thread so it can process other requests, while an additional thread is spawned in the background to handle your long-running request. These days, async ASP.NET pages are pretty easy to use.
jrista