Connection Time out while Uploading files

Many of the developer will be facing the issue Connection Time out while Uploading files. Here we can see how to overcome this timeout error during file upload. HttpRuntime and web.config element are playing main rolls in ASP.NET processes requests, execution timeouts etc..Now let us see how these are get controlled.
executionTimeout – is the maximum time which is allocated for processing a rquest. The defualt values are 90 seconds in ASP.NET 1.x, 110 seconds in ASP.NET 2.0 and above.
maxRequestLength – is the maximum allocated request length for a specific request, it will be in terms of kilobytes.The defualt value is 4096 (4 MB).

Here I am giving an example with the request which has 1GB request length and 10 minute request timeout:

<httpRuntime maxRequestLength=”1048576″ executionTimeout=”600″ />
For the security reson as well as the performance reson, we can restrict this feature for the specific pages . Add this below given code in your web.config file.

<location path=”Page_name.aspx”>
executionTimeout=”600″ />

IIS 7, IIS 7.5 and IIS 8 Configuration

IS 7, IIS 7.5 and IIS 8 has an additional request filtering module which need to be configured seperately. This configuration is controlled by the “requestFiltering/requestLimits” element from web.config(we can do this changes in iis level also).

The request size is controlled by the attribute ‘maxAllowedContentLength’
is the maximum permitted length of content in a request, it will be calculated in bytes. default value is 30000000 (~30MB).

<requestLimits maxAllowedContentLength=”1073741824″/>
If you get an error such as “The requested page cannot be accessed because the related configuration data for the page is invalid” once you added the requestFiltering section in your web.config, then you have to modify the IIS applicationHost.config file to enable you to configure request filtering at the application level instead of the machine level. To do this, open “%windir%\System32\inetsrv\config\applicationHost.config” file in a text editor and make the following changes.

<section name=”requestFiltering” overrideModeDefault=”Deny” />
to  <section name=”requestFiltering” overrideModeDefault=”Allow” />

Leave a Reply

Your email address will not be published. Required fields are marked *