远程服务器返回错误:(413) 请求实体太大 [英] The remote server returned an error: (413) Request Entity Too Large
问题描述
我知道这是一个多余的问题,我在上传超过 100 KB 的文件时遇到错误.
I know this is a redundant question, I am getting the error while I am uploading the a file which is more than 100 KB.
远程服务器返回错误:(413) 请求实体太大.
The remote server returned an error: (413) Request Entity Too Large.
我将内容发布到 WCF 服务(64 位环境).我知道这应该通过管理 maxReceivedMessageSize 和相关行为来解决,但不幸的是它没有.
I am posting the content to a WCF Service (64 bit environment). Am aware this should have been resolved with managing maxReceivedMessageSize and relevant behaviours but unfortunately its not.
以下是我的配置:-
客户
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="BasicHttpBinding_ICandidateManagementService" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message algorithmSuite="Default" clientCredentialType="UserName"/>
</security>
</binding>
<behavior name="CandidateBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<endpoint address="http://localhost:62368/CandidateManagementService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICandidateManagementService" contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior" />
服务
<services>
<service name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior">
<endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/>
</service>
我已经看到了可能所有可用的东西,但仍然无法解决这个问题.也尝试使用以下配置,但仍然没有变化...
I have seen possibly everything available and still cant solve this issue. have also tried using below configuration, but still no change...
<serverRuntime uploadReadAheadSize="500000000" maxRequestEntityAllowed="500000000"/>
请帮忙!
服务绑定配置(与客户端相同)
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="BasicHttpBinding_ICandidateManagementService" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message algorithmSuite="Default" clientCredentialType="UserName"/>
</security>
</binding>
<小时>
下面是提琴手的发现:-
To give more insight below is the fiddlers finding :-
请求计数:1 字节发送:85,719(标头:697;正文:85,022)收到的字节数:10,129(标头:254;正文:9,875)
Request Count: 1 Bytes Sent: 85,719 (headers:697; body:85,022) Bytes Received: 10,129 (headers:254; body:9,875)
推荐答案
经过一番折腾,我的问题终于解决了.我的服务配置存在缺陷,它没有给我任何运行时或编译时错误,因为它甚至无法识别配置.
At last my problem is resolved after struggling a lot. I had a flaw in my Service config, which was not giving me any runtime or compile time error as it was not even recognizing the config.
我的服务配置是:-
<services>
<service name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior">
<endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/>
</service>
我有Name"属性,它不是我的服务的完全限定名称,因此我使用的配置甚至没有被考虑,因此 maxReceivedMessageSize 的默认值是 65KB.
I have the "Name" property which is not fully qualified name of my service, and thus the configuration I used was not even considered and thus was taking default 65KB for maxReceivedMessageSize.
我已经更新了它,它的工作原理非常棒.
I have updated it and its working like a charm.
<services>
<service name="MMJ.Services.CandidateManagementService">
<endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/>
</service>
另外,请查看此帖子以获取更多参考.我知道这是一个愚蠢的错误,感谢大家努力修复.
Also, have a look at this post for more reference. I know this was a silly mistake, and thanks everyone for putting an effort to fix.
这篇关于远程服务器返回错误:(413) 请求实体太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!