Tuesday, March 5, 2013

If we use FileUpload Control To upload Big Or Large Files In Asp.Net,we get error message or uploading fails because of default maximum file size limit of 4mb

we can reset this limit in web.config to enable larger file uploads.

For single application

   1:  <system.web>
   2:   
   3:  <httpRuntime executionTimeout="3600" maxRequestLength="512000"/>
   4:   
   5:  </system.web>
maxRequestLength is the maximum size allowed,this will allow files upto 500 mb to be uploaded.
executionTimeout is number of seconds upload is allowed before being shut down by ASP.NET, this also needs to be increased in case of very large file uploads.

We can allow large files to be uploaded in perticular folder or directory on server either byadding a new web.config file in folder or adding below mentioned code in main web.config.
   1:  <location path="DirectoryToUploadFiles">
   2:  <system.web>
   3:  <httpRuntime executionTimeout="3600" maxRequestLength="512000"/>
   4:  </system.web>
   5:  </location>

To apply limit settings for all the applications on server we can use web.config.commentsconfiguration file in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG

Resetting IIS Server limits
default for IIS server is 30 mb and we can reset this in web.config as mentioned below.
   1:  <system.webServer>
   2:      <security>
   3:        <requestFiltering>
   4:          <requestLimits maxAllowedContentLength="512000"/>
   5:        </requestFiltering>
   6:      </security>
   7:  </system.webServer>

0 comments:

Post a Comment