Which gets priority, maxRequestLength or 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 you need to set both in order to upload large files: the smaller one “takes priority”.

(I picked this up from http://forums.iis.net/t/1169846.aspx — credit where it’s due.)

You can set both to be local to a specific site or even a folder within a site by editing the appropriate web.config file. If the file (well, request) length is less than maxAllowedContentLength but more than maxRequestLength, the user will get your standard (ASPX) error page, if you have one. If it’s the other way around, he’ll get an IIS error page instead. For that reason, you might want to have maxAllowedContentLength to a very large value (just for this website/folder) and then have the limiting value be maxRequestLength.

Finally, remember that maxRequestLength is in KB whereas maxAllowedContentLength is in BYTES!

Leave a Comment