maxReceivedMessageSize not fixing 413: Request Entity Too Large

泄露秘密 提交于 2019-11-27 14:35:59

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.

matt burns

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>

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.

Add this solve it for me:

    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_Example"
 maxBufferSize="2147483647" 
maxReceivedMessageSize="2147483647">
            </binding>
        </basicHttpBinding>
    </bindings>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!