Still getting (413) "Request Entity Too Large" even after setting the web.config in C#

GalloPinto picture GalloPinto · Nov 13, 2013 · Viewed 14.4k times · Source

I'm developing a web application using MVC4 with C#.

I need to send PDFs via AJAX, so I convert them to base64 and send them to a function in C#. That function is going to call another function that is on a web service.

The problem is, the web service function is not getting the base64 string because it's very large, but not TOO large, its about 111,000 characters, like 70kb. I get error 413

pdfCony is my base64 string

enter image description here

I have already set the maxRecievedMesage in my web.config on the web service:

 <bindings>
  <basicHttpBinding>
    <binding name="basicHttpsBinding" maxReceivedMessageSize="524288000" />
    <binding name="mexHttpBinding" maxReceivedMessageSize="524288000" />
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServicioCCMasAvalBehavior" name="ServicioCCMasAval.ServicioCCMasAval">
    <endpoint address="/" binding="basicHttpBinding" contract="ServicioCCMasAval.IServicioCCMasAval" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

So i don't know what is the problem. Help please.

Answer

GalloPinto picture GalloPinto · Nov 13, 2013

Thanks a lot. But I found the solution looking in another web.config example

This was my web.config:

<bindings>
  <basicHttpBinding>
    <binding name="basicHttpsBinding" maxReceivedMessageSize="524288000" />
    <binding name="mexHttpBinding" maxReceivedMessageSize="524288000" />
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServicioCCMasAvalBehavior" name="ServicioCCMasAval.ServicioCCMasAval">
    <endpoint address="/" binding="basicHttpBinding" contract="ServicioCCMasAval.IServicioCCMasAval" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

I was missing the bindingConfiguration on the enpoint. Now this is my working webconfig:

<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" maxReceivedMessageSize="524288000" />
    <binding name="mexHttpBinding" maxReceivedMessageSize="524288000" />
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServicioCCMasAvalBehavior" name="ServicioCCMasAval.ServicioCCMasAval">
    <endpoint address="/" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="ServicioCCMasAval.IServicioCCMasAval" />      
  </service>
</services>

Realy really thanks a lot.