maximum request length exceeded while uploading file asp.net code example

Example: iis Maximum request length exceeded

Modify web.config adding these elements:
  <configuration>
    <system.web>
      <httpRuntime maxRequestLength="1048576" />
    </system.web>
  </configuration>

For IIS7 and above (included IIS Express), you also need to add:
 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>
 
Note:
maxRequestLength is measured in kilobytes
maxAllowedContentLength is measured in bytes

Tags:

Misc Example