[Originally posted by]: http://stackoverflow.com/questions/23327338/maxrequestlength-for-net-4-5-1-framework
If you are hosted in IIS, you need two settings:
- maxRequestLength – for ASP.net (measured in KB)
- maxAllowedContentLength – for IIS (measured in Bytes)
Sample config: (this is for 100MB upload limit)
<configuration> <system.web> <httpRuntime maxRequestLength="102400" executionTimeout="3600" /> </system.web> </configuration> <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="104857600" /> </requestFiltering> </security> </system.webServer>
The smaller of the two will take precedence. For IIS, the default is 4MB.
Both throws different exceptions.
maxRequestLength– Whenever a file exceeds this setting, you’ll get an Application_Error (standard ASP error)
maxAllowedContentLength– Whenever a file exceeds this setting, you’ll get IIS error.
The IIS error is harder to debug, so it is advisable that you set the
maxRequestLength is easier to catch since its at application level.