maxRequestLength And maxAllowedContentLength

maxRequestLength indicates the maximum request size supported by ASP.NET, whereas maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. So we need to set both in order to upload large files: the smaller one takes priority.

Setting for maxRequestLength 
  <system.web>
            <httpRuntime maxRequestLength="153600" executionTimeout="900" />
  </system.web>

Setting for maxAllowedContentLength 
 <system.webServer> 
         <security>
                 <requestFiltering>
                           <requestLimits maxAllowedContentLength="157286400" />
                 </requestFiltering>
         </security> 
</system.webServer>

If the file (request) length (say, 15MB) is less than maxAllowedContentLength (say, 30MB) but more than maxRequestLength (say, 10MB), the user will get the standard ASPX error page, if server has one. If it's the other way around, we'll get an IIS error page instead. 
For this reason, we should have maxAllowedContentLength to a very large value (100 MB) (just for this website/folder) and then have the limiting value be maxRequestLength (10 MB).
Remember that maxRequestLength is in KB whereas maxAllowedContentLength is in Bytes.

Comments

Popular posts from this blog

Data Bound Controls in ASP.Net - Part 4 (FormView and DetailsView controls)

ASP.net: HttpHandlers

The Clickjacking attack and X-Frame-Options