【问题标题】:WCF (413) Request Entity Too Large - also after changing configurationWCF (413) 请求实体太大 - 也在更改配置后
【发布时间】:2017-02-07 10:47:46
【问题描述】:

当我尝试通过 WCF 服务发送更大的数据时,我遇到了与错误 413 Request Entity Too Large 有关的问题。我更改了配置,添加了 maxReceivedMessageSize 和其他一些,但没有帮助。 下面我粘贴我的配置: 服务器端配置:

<system.serviceModel>
<services>
  <service behaviorConfiguration="BasicBehavior" name="xxx">
    <endpoint address="" behaviorConfiguration="EndpointBehavior" bindingConfiguration="BasicBinding"
      binding="basicHttpBinding" name="GenerateDocuments" contract="xxx" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="BasicBinding" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
       <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        <security mode="None">
        <transport clientCredentialType="None"/>
        </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="BasicBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="EndpointBehavior">
    </behavior>
  </endpointBehaviors>
</behaviors>

这是我在客户端的绑定配置(客户端配置是以编程方式创建的):

BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "BasicBinding";
binding.SendTimeout = new TimeSpan(0, 5, 0);
binding.Security.Mode = BasicHttpSecurityMode.None;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.MaxBufferPoolSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.ReaderQuotas.MaxDepth = 2000000;
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;

最后客户端调用服务:

GenerateDocumentsClient service = new GenerateDocumentsClient(ConnectionManager.GetBinding(), ConnectionManager.GetEndpoint(MainFields.DatabaseRegister))

我还更改了属性 uploadReadAheadSize,但它也没有帮助。 我不知道我该怎么做才能使它正确。如有任何帮助,我将不胜感激。

【问题讨论】:

    标签: c# wcf configuration-files


    【解决方案1】:

    在服务 web.config 中试试这个(在 system.serviceModel 之前):

      <system.web>
           <httpRuntime maxRequestLength="2147483647" />
      </system.web>
         <system.webServer>
         <security>
             <requestFiltering>
                    <requestLimits maxAllowedContentLength="2147483647"></requestLimits>
              </requestFiltering>
          </security>
      </system.webServer>
    

    【讨论】:

    • 它也没有帮助。我之前在 IIS 中配置过 :(
    【解决方案2】:

    好的,这个话题可以关闭了。我找到了一个非常愚蠢的原因,为什么我不能这样做,所以问题就解决了。

    【讨论】:

    • 如果问题不再相关,您可以将其删除,因为您提出了它。
    • 请问您是怎么​​解决这个问题的?我们也处于同样的境地。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2016-09-08
    • 2020-02-05
    • 2011-02-22
    • 1970-01-01
    • 2016-11-14
    • 2014-12-30
    • 2014-12-23
    相关资源
    最近更新 更多