maxReceivedMessageSize not fixing 413: Request Entity Too Large

tried things from 10 different blogs and my coworker figured it out. we had to add a basicHttpsBinding section inside of in addition to the basicHttpBinding section. We have a webapi service calling wcf. the webapi method was catching the entity too large error when it called the wcf service method. This change was applied in the web.config file of the wcf service.


I also had this problem and realized in fiddler that the max Content-Length that was working ended up being 30000000.

After verifying that my WCF configuration was correct I found an article suggesting a modification to the IIS setting, Request Filtering.

Large file upload failure for Web application calling WCF service – 413 Request entity too large

  1. Open IIS Manager
  2. Select your application
  3. Select the Request Filtering icon.
  4. Select Edit Feature Settings... (Right Panel)
  5. Adjust the Maximum allowed content length (Bytes) Default Appears to be 30000000

or web.config file example

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="50000000" />
    </requestFiltering>
  </security>
</system.webServer>

The answer was staring me in the face.

The config generated by svcutil was for the client. I was using it on the server.

I was editing the bindings for the endpoints specified under <client>, which made absolutely no difference to the service.

Adding a proper <service> endpoint and setting the maxReceivedMessageSize and maxBufferSize on its binding resolved the issue.


I had a similar problem. For me, the problem was that my endpoint did not explicitly name the binding using bindingConfiguration and so must have been using some default one somewhere.

I had:

<webHttpBinding>
    <binding 
        name="myXmlHttpBinding" 
        maxReceivedMessageSize="10485760" 
        maxBufferSize="10485760">
        <readerQuotas 
            maxDepth="2147483647" 
            maxStringContentLength="2147483647" 
            maxArrayLength="2147483647" 
            maxBytesPerRead="2147483647" 
            maxNameTableCharCount="2147483647"/>
        <security mode="None"/>
    </binding>
</webHttpBinding>

and my endpoint defined as:

<service 
    name="blah.SomeService">
    <endpoint 
        address="" 
        behaviorConfiguration="WebHttpBehavior" 
        binding="webHttpBinding" 
        contract="blah.ISomeService">

        <identity>
            <dns value="localhost"/>
        </identity>
    </endpoint>
</service>

It worked once I changed the endpoint to:

  <service name="blah.SomeService">
    <endpoint address="" 
        behaviorConfiguration="WebHttpBehavior" 
        binding="webHttpBinding" 
        bindingConfiguration="myXmlHttpBinding" 
        contract="blah.ISomeService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
  </service>