Thread: Changing maxAllowedContentLength

In a .NET application used to deliver quizzes, attempting to import a large quiz from another server resulted in this error:

“The request filtering module is configured to deny a request that exceeds the request content length.” A second message stated:
“Request filtering is configured on the Web server to deny the request because the content length exceeds the configured value.”

To fix this error we need to increase the maxAllowedContentLength setting in the relevant web.config file.

Here’s how to use the appcmd.exe command-line tool to make changes to the the web.config or applicationhost.config file.

Click Start, type “command prompt” in the Start Search box, right-click Command Prompt in the Programs list, and click Run as administrator.

If you are prompted for an administrator password or for confirmation, type your password, or click Continue.

Change to the right directory by typing

cd windowssystem32inetsrv

then click Enter.

Type

appcmd set config /section:httpRedirect /enabled:true

then click Enter, or if you want to make the change only for one application, type:

appcmd set config "Default Web Site/" -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000

Thanks to Thomas Deml for this tip.