【问题标题】:WCF: request entity too largeWCF:请求实体太大
【发布时间】:2021-12-17 20:04:45
【问题描述】:

我正在上传 26 MB 的 pdf,但在上传 pdf 时出现以下错误

远程服务器返回意外响应:(413) 请求 实体太大。

我正在尝试upload的PDF

我的 WCF web.config

<bindings>
  <basicHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Buffered"
    closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <readerQuotas maxDepth="2000000000"
      maxStringContentLength="2000000000"
      maxArrayLength="2000000000"
      maxBytesPerRead="2000000000"
      maxNameTableCharCount="2000000000" />
    </binding>
  </basicHttpBinding>
</bindings>

我的网络应用程序 web.config

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647" />
  </basicHttpBinding>
</bindings>

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483647" />
  </requestFiltering>
</security>

相同的代码在本地运行良好,但是当我将这些更改发布并托管到 IIS 中时,我收到了错误

远程服务器返回意外响应:(413) 请求 实体太大。

我在 stackoverflow 上看到了多个问题和答案,但仍然无法理解问题所在

【问题讨论】:

    标签: c# wcf file-upload


    【解决方案1】:

    我认为您需要检查服务配置。

    【讨论】:

    • 我的 service.config 的哪个部分?
    • 您可以检查端点是否在配置中明确定义,并将您的绑定配置分配给端点的bindingConfiguration属性。 &lt;services&gt; &lt;endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService" /&gt;&lt;/services&gt;具体可以参考:stackoverflow.com/questions/20575946/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 2020-02-05
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 2019-10-07
    相关资源
    最近更新 更多