简体   繁体   English

在C#中设置web.config后仍然得到(413)“Request Entity Too Large”

[英]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#. 我正在使用带C#的MVC4开发一个Web应用程序。

I need to send PDFs via AJAX, so I convert them to base64 and send them to a function in C#. 我需要通过AJAX发送PDF,所以我将它们转换为base64并将它们发送到C#中的函数。 That function is going to call another function that is on a web service. 该函数将调用Web服务上的另一个函数。

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. 问题是,Web服务函数没有得到base64字符串,因为它非常大,但不是TOO大,它大约111,000个字符,如70kb。 I get error 413 我收到错误413

pdfCony is my base64 string pdfCony是我的base64字符串

在此输入图像描述

I have already set the maxRecievedMesage in my web.config on the web service: 我已经在web服务的web.config中设置了maxRecievedMesage:

 <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 但我发现解决方案在另一个web.config示例中查找

This was my web.config: 这是我的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. 我错过了enpoint上的bindingConfiguration。 Now this is my working webconfig: 现在这是我的工作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. 这是正确的配置,但我认为Visual Studio有自己的配置文件,因此当您处于调试模式时,您实际上必须将Visual Studio的app.config更改为与C:\\ Program Files(x86)\\相同的路径我相信Microsoft Visual Studio 10.0 \\ Common7 \\ IDE \\ EXE。 Also there is maxSend not sure if you have them flipped 还有maxSend不确定你是否翻过它们

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, 我有同样的问题,但对于我的情况,我不得不传输非常大的文件(超过1Go),绑定配置必须在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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