WCF:远程服务器返回错误:(413)请求实体太大[重复]
Posted
技术标签:
【中文标题】WCF:远程服务器返回错误:(413)请求实体太大[重复]【英文标题】:WCF: The remote server returned an error: (413) Request Entity Too Large [duplicate] 【发布时间】:2014-07-23 10:56:36 【问题描述】:我有一个 wcf 服务
有一种方法可以获取 base64 字符串来上传文件,我的文件大小为 100kb,它可能会及时变大
我收到错误消息:远程服务器返回错误:(413)请求实体太大 同时尝试获取 HttpWebResponse
这是我的 wcf 服务 web.config
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity" allowCookies="false" maxReceivedMessageSize="104857600">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="FHServices.FHSmartService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="FieldHoundServices.IFHSmartService" behaviorConfiguration="web">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost/FHServices/FHSmartService.svc/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我的错误是什么?
解决了
我发现了我的错误 我删除了这些代码
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
我认为 https 的传输模式,我们没有 ssl,所以我们不需要传输模式。不管怎样,我删除它后,现在一切正常
【问题讨论】:
可能与此有关:***.com/questions/884235/… 增加服务器允许您传输的消息大小。 我将 maxReceivedMessageSize 设置为 2147483647 但仍然是同样的错误 ***.com/questions/10122957/… ***.com/questions/23513785/… 【参考方案1】:您没有将定义的WebHttpBinding
配置分配给您的端点,因此端点使用默认值进行绑定。
您可以通过在<endpoint>
元素的bindingConfiguration
属性中指定它来告诉端点使用您的绑定配置,如下所示:
<endpoint address="" binding="webHttpBinding"
bindingConfiguration="webHttpTransportSecurity"
contract="FieldHoundServices.IFHSmartService"
behaviorConfiguration="web">
</endpoint>
【讨论】:
谢谢,很好的回答......以上是关于WCF:远程服务器返回错误:(413)请求实体太大[重复]的主要内容,如果未能解决你的问题,请参考以下文章
(413) 请求实体太大 - 在 Azure 上上传 Wcf 时
WCF 413 请求实体太大 - 自托管 WebHttpBinding