01 May 2012

Time Out downloading large files

When your downloading a table data in the format of excel sheet, while doing that it throws time out error due to lack of enough size. To download the file add the following tag in the web.config file as shown below.
Problem:

By default, Machine.config is configured to accept HTTP Requests upto 4096 KB (4 MB) and it is reflected in all your ASP.NET applications. You can change the Machine.config file directly, or you can change only the Web.config file of the application(s) you want to.
Open your Web.config file, and just below the <system.web> tag, add the following tag:

  <system.web>
    <httpRuntime executionTimeout="90"
            maxRequestLength="4096"
            useFullyQualifiedRedirectUrl="false"
            minFreeThreads="8"
            minLocalRequestFreeThreads="4"
            appRequestQueueLimit="100"
            enableVersionHeader="true"
    />
Now, just take a look at the maxRequestLength="4096"  and   executionTimeout="1000" attribute of the  <httpRuntime>  tag. As you may have realized, all you need to do is change the value to some other value of your choice (8192 for 8 Mb, 16384 for 16 Mb, 65536 for 64 Mb, and so on...).

No comments:

Post a Comment