简体   繁体   English

WCF错误:远程服务器返回错误:(413)请求实体太大

[英]WCF error: The remote server returned an error: (413) Request Entity Too Large

I created a WCF service to upload the 1MB file data into Windows Server. 我创建了一个WCF服务,将1MB文件数据上传到Windows Server。 This web service is working fine with small file (950 KB) data but it has an issue with larger file size. 此Web服务可以正常使用小文件(950 KB)数据,但它存在较大文件大小的问题。

I tried several ways to fix it in WCF web.config but still stuck in above error. 我尝试了几种方法来修复它在WCF web.config中,但仍然陷入上述错误。 I need helps to setup on WCF configuration to resolve my issue. 我需要帮助设置WCF配置来解决我的问题。

Here are my web.config as following: 这是我的web.config如下:

<system.serviceModel>
    <services>
      <service name="WCFService.UploadService">
        <endpoint address="REST" behaviorConfiguration="WCFServiceBehavior" binding="webHttpBinding" bindingConfiguration="WCFServiceBinding" contract="WCFService.IUploadService" />
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="WCFServiceBinding" maxReceivedMessageSize="1073741824" maxBufferSize="20971520" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WCFServiceBehavior">
          <webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
  </system.serviceModel>

Kindly correct above WCF web.config 请在WCF web.config之上更正

Please refer to the below configuration, it supports both Http and Https. 请参考下面的配置,它支持Http和Https。 You can cut it as needed. 你可以根据需要切割它。 Besides, I use the ProtocolMapping feature to simplify my configuration. 此外,我使用ProtocolMapping功能来简化我的配置。

<system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" name="httpbinding">
          <security mode="None">
          </security>
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147473647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
        </binding>
        <binding name="httpsbinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147473647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <!--http and https are all supported.-->
      <add binding="webHttpBinding" scheme="http" bindingConfiguration="httpbinding"/>
      <add binding="webHttpBinding" scheme="https" bindingConfiguration="httpsbinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

For how to simplify the configuration, 对于如何简化配置,
https://docs.microsoft.com/en-us/dotnet/framework/wcf/simplified-configuration https://docs.microsoft.com/en-us/dotnet/framework/wcf/simplified-configuration
Feel free to let me know if the problem still exists. 如果问题仍然存在,请随时告诉我。

暂无
暂无

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

相关问题 远程服务器返回错误:(413)请求实体太大 - The remote server returned an error: (413) Request Entity Too Large WCF服务“远程服务器返回错误:(413)请求实体太大。” - WCF Service “The remote server returned an error: (413) Request Entity Too Large.” WCF 4.5:发生意外错误:远程服务器返回了意外响应:(413)请求实体太大 - WCF 4.5: An unexpected error occurred: The remote server returned an unexpected response: (413) Request Entity Too Large WCF 服务与 30mb 输入字符串 - 远程服务器返回错误:(413)请求实体太大 - WCF service with 30mb input string - The remote server returned an error: (413) Request Entity Too Large 上载大图像时WCF服务错误-远程服务器返回意外响应:(413)请求实体太大 - WCF service error while uploading large images - the remote server returned an unexpected response: (413) request entity too large Exchange Web 服务 - 请求失败。 远程服务器返回错误:(413) 请求实体太大 - Exchange Web Services - The request failed. The remote server returned an error: (413) Request Entity Too Large (413)使用WCF请求实体太大错误 - (413) Request Entity Too Large error with WCF WCF中的请求实体太大错误(413) - Request entity too large error(413) in WCF 错误:远程服务器返回了意外的响应:(413)请求实体太大 - Error: the remote server returned an unexpected response: (413) Request Entity Too Large 文件上传,远程服务器返回错误:(413) Request Entity Too Large - File Upload, The remote server returned an error: (413) Request Entity Too Large
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM