Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 641
skmasq Avatar asked Jun 03 '12 16:06

skmasq


People also ask

How do I enable request filtering in IIS 10?

Open IIS Manager and select the level for which you want to configure request filter. In Features View, double-click Request Filtering. In the Actions pane, click Edit Feature Settings. In the Edit Request Filtering Settings dialog, edit the settings as desired, and then click OK.

How do I turn off filtering requests?

Briefly, a filter can be removed by modifying any isapiFilters element you may find (or by adding one if needed, see below), and then adding a single line "remove" element, naming the filter you want to remove,. Beware the filter name is case-sensitive. This would be found or placed one level inside of the system.

What is Requestlimits maxAllowedContentLength?

maxAllowedContentLength. Optional uint attribute. Specifies the maximum length of content in a request, in bytes. The default value is 30000000 , which is approximately 28.6MB.


2 Answers

<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> 
like image 134
Stan Avatar answered Oct 22 '22 15:10

Stan


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

like image 43
stink Avatar answered Oct 22 '22 14:10

stink