[Solved] Maximum Request Length Exceeded Uploading Large Files asp.net c#

Maximum Request Length Exceeded Solution

One of the major problem we need to take care of while uploading large files in asp.net web application is its size. Normally an asp.net web application allows maximum of 4MB of file size to be uploaded to the system. You will get an error message like below while uploading larger files than 4MB
Maximum request length exceeded problem asp.net c# File Upload
Maximum Request Length Exceeded

Solution

To fix this problem, if your using IIS (Internet Information Services) below version 7, then you need to add following lines of codes in your web.config file
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

If you are using IIS version greater than version 7 (or 7), then you must add following code
<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

Note that both above configuration are equivalent to 1GB.
maxRequestLength is measured in kilobytes
 
&
maxAllowedContentLength is measured in bytes

Additional Note

If you are using large file, it takes time to upload, so use executionTimeout property to increase the time of waiting, otherwise the process will not wait until the file upload completes, and automatically the file upload will be crashed. to over come this problem use like below configuration
 
<httpRuntime maxRequestLength="1048576" executionTimeout="100000" />
[Solved] Maximum Request Length Exceeded Uploading Large Files asp.net c# [Solved] Maximum Request Length Exceeded Uploading Large Files asp.net c# Reviewed by Tech Doubts on 11:37 PM Rating: 5

No comments:

Powered by Blogger.