IIS7 - The request filtering module is configured to deny a request that exceeds the request content length
Solution 1
<configuration>
<system.web>
<httpRuntime maxRequestLength="1048576" />
</system.web>
</configuration>
From here.
For IIS7 and above, you also need to add the lines below:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
Solution 2
The following example Web.config file will configure IIS to deny access for HTTP requests where the length of the "Content-type" header is greater than 100 bytes.
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits>
<headerLimits>
<add header="Content-type" sizeLimit="100" />
</headerLimits>
</requestLimits>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Source: http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits
skmasq
Updated on July 08, 2022Comments
-
skmasq almost 2 years
I want to upload images, it works fine on my machine but when I put my website on IIS7 server for public I can't upload anything.
Error
The request filtering module is configured to deny a request that exceeds the request content length.
Most likely causes
Request filtering is configured on the Web server to deny the request because the content length exceeds the configured value.
Things you can try
Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file.
system.webServer in Web.config
<system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true" /> <security> <requestFiltering> <requestLimits maxAllowedContentLength="1048576" /> </requestFiltering> </security> </system.webServer>
As you can see I set my maxAllowedContentLength to 1gb. Restarted my website and still getting this error. I made an
/uploads/
folder on my file system where it suppose to be as well. Have no idea what causes this error and why I can't upload images. -
Malachi almost 9 yearscould you please explain what you did to fix the issue?
-
Zeeshan over 8 yearsI don't know how, but this solution worked for me. I was having configuration error saying:
HTTP Error 404.7 - Not Found. The request filtering module is configured to deny the file extension.
while trying to run existingwcf
project inRole
of newAzure Cloud Service
. I added these lines inweb.config
of existingwcf
project, and it worked -
stink over 8 years@zeeshan I wouldn't spend too much time troubleshooting Azure server configs.... There are some other gotchas.
-
iamnicoj over 8 yearsyou are missing half the story.. you need to configure also MaxAllowedContentLength
-
David Rogers over 7 years@LaPuyaLoca is correct, this is half an answer, I think the full one is provided here.
-
Kyle Houston - Phi Anh about 2 yearsThis method is not helpful at all. When I delete as your note the file applicationhost.config ran into error