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

14,416

Solution 1

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.

Solution 2

I had the same problem, but for my case, I had to transfer very big files (more than 1Go), and the binding Configuration had to be on Streamming,

So here are how I fixed my issue :

<bindings>
  <basicHttpBinding>
    <binding name="HttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed"/>
  </basicHttpBinding>

  <!-- an example customBinding using Http and streaming-->
  <customBinding>
    <binding name="Soap12">
      <textMessageEncoding messageVersion="Soap12WSAddressing10" />
      <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/>
    </binding>
  </customBinding>
</bindings>

<services>
  <service name="FileTransferService">
    <endpoint address="http://localhost:40040/FileTransferService.svc" binding="basicHttpBinding" bindingConfiguration="HttpStreaming" name="NameSpace.FileTransferService" contract="NameSpace.IFileTransferService" />
  </service>
</services>

Solution 3

this is the proper config, but I think Visual Studio has its own config file so when you are in debug mode you actually have to change app.config for Visual Studio its in the same path as the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ EXE I believe. Also there is maxSend not sure if you have them flipped

If your are debugging remotely disregard this answer

Share:
14,416

Related videos on Youtube

GalloPinto
Author by

GalloPinto

Updated on September 16, 2022

Comments

  • GalloPinto
    GalloPinto over 1 year

    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.

  • d1jhoni1b
    d1jhoni1b about 10 years
    LOL thanks man! i was missing the bindingConfiguration attribute on the enpoint too ! >.<
  • Patrick M
    Patrick M almost 10 years
    Please clarify: is your XML snippet how you fixed the asker's question? If you have not solved the problem, consider Asking a New Question.
  • xspirata
    xspirata almost 10 years
    This is how I fixed it. I tried the other resolutions in this page, but they didn't work for me (with TXT files bigger than 1Go). So I put a custom binding in Streamming mode.