X

The request filtering module is configured to deny a request that exceeds the request content length

I have a file upload Web application running perfectly fine on IIS 6 server, but when I migrated it to an IIS 7 server, when I try to upload a large file, it throws an error saying:

The request filtering module is configured to deny a request that exceeds the request content length.

It puzzled me because I have this setting in my Web.config file:

<httpRuntime maxRequestLength="2097151" executionTimeout="7200" />

This setting should allow me to upload files up to 2 GB, but when I try to even upload a 20MB file, it throws the above error on me.

If you read the More Information section of the error, you will find that this is a security feature. In order to override the size limit on IIS 7, you can run a command specified in this post on iis.net web site: http://forums.iis.net/p/1066272/1543441.aspx

But if you don’t have access to the server, you can actually modify your application’s Web.config. Open your Web.config file, then find a section called <system.webServer> towards the end of the Web.config file. Then add this settings in it.

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483649"></requestLimits>
</requestFiltering>
</security>

You may find that if you manually type in the above code, the Intellisense does not show any sections mentioned above, but it is ok. I guess it is by design for hiding those sections from Intellisense so no mistake will be made inadvertently.

Once I have the above code in place, my file upload application starts working again.

Summary:

<httpRuntime maxRequestLength="2097151" executionTimeout="7200" />

is for IIS 6 server, but on IIS 7 server, you need:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483649"></requestLimits>
</requestFiltering>
</security>

and you can have both in your Web.config, this way, your application will work on both IIS 6 and IIS 7.

0 0 votes
Article Rating
Jeffrey:
Related Post