[英]Error 413 Request Entity Too Large
我遇到錯誤(413) Request Entity Too Large
。 我已經進行了一些搜索,所能看到的是,需要將maxRecievedMessageSize
添加到綁定中,並且需要在bindingConfiguration
添加bindingConfiguration
。 我已經在客戶端web.config和服務web.config上執行了這些步驟。
客戶
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
...
<endpoint address="https://mysite.com/WcfServices/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="secureHttpBinding"
contract="MyService.IMyService" name="BasicHttpBinding_IMyService" />
世界足球聯合會
<basicHttpBinding>
<binding name="secureHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
我沒有在WCF web.config中顯式指定任何<service>
標記,但是在未顯式定義標記之前,我已經取得了成功。 這里還有其他問題嗎?
使用SSL / TLS時,在某些情況下,IIS可以緩沖整個HTTP請求,然后再將其傳遞給WCF。 該緩沖區的默認大小僅為48k,如果超出該緩沖區,IIS將返回413錯誤。
要解決此問題,必須通過uploadReadAheadSize
設置增加緩沖區的大小。 在IIS 7.5中,可以通過IIS管理器獲得此設置:
system.webServer/serverRuntime
,從: ApplicationHost.config
。 uploadReadAheadSize
設置為所需的緩沖區大小(以字節為單位)。 確保它大於您可能發送的最大請求。 對於其他IIS版本,此設置可能位於其他位置。
也可能會有其他原因獲得413,但這是我遇到的原因。 當然,如果您不在IIS中托管服務,則顯然不適用。
您在服務配置文件中定義的basicHttpBinding
沒有使用,因為它沒有分配給端點。 在WCF 4.0+中,如果未顯式指定端點,則將獲得具有默認綁定的默認端點-並且http
的默認綁定是basicHttpBinding
。 但這也意味着您將獲得綁定的默認值。
您可以顯式添加服務端點並為其分配綁定,也可以通過在定義中省略name
屬性,使定義成為basicHttpBinding
的默認定義,如下所示:
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
然后,上面的配置片段將為basicHttpBinding
設置您的定義,因為該應用程序中使用basicHttpBinding
任何服務的默認設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.