maxReceivedMessageSize not fixing 413: Request Entity Too Large

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>

Leave a Comment