Troubleshooting – IIS RequestFiltering

The Microsoft Azure App Service can host Web Apps that are built using various stacks. Although we aren’t using .NET for our App, it’s important to remember that this service uses IIS to route traffic to the underlying Application Servers. Whether we’re using PHP or Java, we need to be familiar with the Web.Config. This file has its origins in ASP.NET and is used to configure the IIS pipeline.

If you’re uploading resources through your Web App, chances are that you’ve observed the following error message.

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

Web.Config Example

This example, configures both the maximum request length and the maximum content length. This file must be placed at the root App.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <!-- maxRequestLength is in kilobytes (KB)  -->
    <httpRuntime maxRequestLength="4194303" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- maxAllowedContentLength is in bytes (B)  -->
        <requestLimits maxAllowedContentLength="4294967295"/>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Things That we Should Keep in Mind

  • maxRequestLength is in kilobytes (KB)
  • maxQueryString is in bytes (B) and of type uint. Its default value is 2048
  • maxUrl is in bytes (B) and of type uint. Its default value is 4096
  • maxAllowedContentLength is in bytes (B) and its default value is 30000000, which is about 28.61 MB. Its type is uint, and its max value is 4,294,967,295 bytes = 3,99 GB

Resources

One response to Troubleshooting – maxAllowedContentLength Exceeded

  1. 

    Hey I was using works goof on local IIS Express but when I deploy aspnet core app to azure Web app it does not works for request having a payload greater than 25 MB ang gives 404 error ,

    Can You help on this

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.