22
votes

I have a simple webmethod

[WebMethod]
public int myWebMethod(string fileName, Byte[] fileContent)

However, whenever I pass a byte array which is larger than 30mb, I get the error:

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

My web.config is as follows:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"> </compilation>
    <authentication mode="Windows" />
    <httpRuntime useFullyQualifiedRedirectUrl="true"
                 maxRequestLength="102400" requestLengthDiskThreshold="102400"
    />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="104857600"/>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

I've searched around, and the most common cause of this problem is the maxAllowedContentLength property being 30mb by default. However, I have set this to be 100mb, as well as the maxRequestLength property for httpRuntime.

I can't find a solution anywhere which isn't setting one of the properties I've already tried above. Is there something I have missed?

2
This is happening to me too in 7.5: I truly believe this is an IIS bug with no solution. SO: stackoverflow.com/questions/16365483/… IIS Forums: forums.iis.net/post/set/1043/1197751/2049386jocull
The particular problem here for me is really with SSL - over plain HTTP everything responds as expected. However, once the SSL is turned on it starts to hang.jocull
It's possible there's an IIS incompatibility with SSL as documented here: bitbucket.org/tortoisehg/thg/issue/2593/… - What a pain to discover!!!jocull

2 Answers

12
votes

You problem may lie in the fact that settings made in the web.config file may be superseded by corresponding settings present in both the applicationhost.config and machine.config files.

If you have access to these, check if the overrideModeDefault property of the corresponding sections are set to Allow, as in the following example:

machine.config

<requestFiltering overrideModeDefault="Allow">
    <requestLimits maxAllowedContentLength="104857600"/>        
</requestFiltering>

AFAIK there is no way to override these settings if you don't have access to the corresponding configuration file.

You may find more information about system-wide configuration and settings override here, here and here - and a very similar case here.

-2
votes

This is pretty old. But I have the same problem today. To fix this, you need to make the necessary setting changes in web.config, then deploy to the web server. The important part is that you need to re-deploy your application to the web server. By doing so, the IIS settings are updated for you. Depending on how you do your deployment, you may need to delete your web application from the web server first, then deploy again. Updating web.config in place won't fix the problem. Hope this helps others with the same problem.