简体   繁体   中英

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

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

在此输入图像描述

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.

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.

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM