Prevent Request Timeout in Asp.net

In one of our application we want our user to upload data up to 1GB and the most interesting part is we want this uploading via HTTP. I mean, we have plan to use FTP but that is for future. For now we need to make it with HTTP.

Off course, uploading data in GB’s requires much extra time then the default configuration and same problem with the request size. So, to make it done we need to change the configuration of following items.

  1. executionTimeOut : Default value is 110 seconds, we need to make it for at least 12 hours.
  2. maxRequestLength : Default value is 4096 KB (4 MB), we want it to accommodate 1 GB size of data.
  3. Session Timeout : Default value is 20 minutes, we need to make it according to the executionTimeOut.

The above two are the configuration of httpRuntime attribute, but along with that why do we need to change the session timeout. Because, if session timeout is less then execution timeout it means when the request finishes its processing meanwhile, the session get’s end which can raise an error.

So, here is the configuration which we need to make in web.config.

   1: <httpRuntime executionTimeout="43200" maxRequestLength="104856"  />
   2: <sessionState mode="InProc" cookieless="false" timeout="720"/>

Notice, executionTimeout needs to be filled in seconds where as timeout of sessionstate needs minutes as input.

But that doesn’t work in my case. I spent many hours replacing the configuration settings and no results.

Finally, I get to know that Application Pool also have idle timeout settings which can be useful.


To get application pool in Windows 2003  :

  1. Right click on your website and click properties
  2. Then Home Directory Tab and notice the last most drop down of  screen. Application Pool
  3. Notice the name, and close screen.
  4. Then go to Application Pools right click the application name which you have in our website and then properties. You will see the following Screen.

 

idle

The default value of idle timeout is 20 minutes. I have changed this to 720 (same as of session) minutes and every thing start working.

I did never even hear of this idle timeout before neither I think that while uploading the file connection thread is idle but now this is for sure, if you are increasing the session timeout greater then 20 you must need to configure the same amount in your Application Pool Settings.

Published Friday, February 20, 2009 1:34 AM by aghausman12
Filed under: , ,

Comments

# re: Prevent Request Timeout in Asp.net

Wednesday, March 18, 2009 6:54 PM by Prab Singh

Thank you for this post.

# re: Prevent Request Timeout in Asp.net

Wednesday, March 25, 2009 3:27 AM by Sam

Thanx. Useful stuff.

# re: Prevent Request Timeout in Asp.net

Monday, June 8, 2009 2:27 AM by Mr. Majid Ali

Thanks.Useful stuff.

# re: Prevent Request Timeout in Asp.net

Monday, June 8, 2009 2:33 AM by Mr.Majid Ali(PAK)

It should work if you place it within <system.web> as follows:

<configuration>

 <system.web>

   <

httpRuntime executionTimeout="1000" maxRequestLength="2000000" />

# re: Prevent Request Timeout in Asp.net

Friday, December 18, 2009 3:49 PM by bcanonica

Great post helped me out big time.  We have a similar venture.  

# re: Prevent Request Timeout in Asp.net

Thursday, February 4, 2010 2:55 PM by Asif Ashraf

Thanks buddy, nice to see people doing from pk.

AH

# re: Prevent Request Timeout in Asp.net

Wednesday, May 18, 2011 4:05 PM by PatrickRR

There is an easy way to keep a session alive for hours and hours with no IIS or config changes.

snippets.surfthru.com/.../Stop-ASPNET-Session-Timeouts.aspx

Leave a Comment

(required) 
(required) 
(optional)
(required)