Cry about...
MS-Windows Troubleshooting


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


Symptom:

When trying to upload a large file to a webserver the following error is generated in the browser:

Server Error
404 - File or directory not found.
The resource you are looking for might have bene removed, had its name changed, or is temporarily unavailable.

However, the upload is performed on the server itself (or the server is configured to show errors) then the error shown is instead:

HTTP Error 4014.13 - Not Found
The request filtering module is configured to deny a requst that exceeds the request content length.

Cause

There are limits set on the maximum size of data that can be posted to the server. This is to avoid inappropriate requests from clogging up bandwidth and system resources. Basically a request that is too large is considered to be a threat and blocked.

Remedy:

Edit the web.config file for the application, and add a setting for "maxAllowedContentLength".

The default for maxAllowedContentLength is 30000000 bytes (30,000,000 bytes). The units are bytes (not KB or MB, but bytes). The maximum value is 4294967295 bytes (4,294,967,295 bytes).

For example, the following will set the limit to 60,000,000 bytes (twice the default):

<configuration>
  .
  .
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="60000000"/>
      </requestFiltering>
    </security>
  </system.webServer>
  .
  .
</configuration>

Do read the "gotcha" below, as you will probably need to adjust maxRequestLength too.

Gotcha!

Be aware that once you change the limit you might then encounter a different error:

Server Error in '/' Application
Maximum request length exceeded

in which case you also need to increase the value for maxRequestLength. maxRequestLength is specified in KB and has the default value of 4096KB.

To set the maxRequestLength to allow for the 60,000,000 content length setting above use:

<configuration>
  .
  .
  <system.web>
    <httpRuntime maxRequestLength="60000"/>
  </system.web>
  .
  .
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="60000000"/>
      </requestFiltering>
    </security>
  </system.webServer>
  .
  .
</configuration>

Note: 60,000KB is actually slightly larger than 60,000,000 byte, but for the sake of an example I'm ignoring that.


These notes are believed to be correct for .NET 4.0, and may apply to other versions as well.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.