(413)使用WCF请求实体太大错误

时间:2012-11-26 15:03:04

标签: c# wcf iis

我正在尝试构建一个允许用户上传文件的WCF服务,文件将限制为最大2mb。我将一个byte []传递给服务,但不断收到以下错误: System.Net.WebException:远程服务器返回错误:(413)请求实体太大。

我能够发送1kb和10kb的文件,但是当我尝试像82kb这样的大文件时,我得到了那个错误。我已经浏览了一些以前的帖子,但似乎找不到我做错了什么,我也尝试调整配置中的设置,设置最大值以查看是否有帮助,但没有任何工作至今。有人可以看看我有什么,看看我是否遗漏了什么,或者这是与IIS(7.5)有关的东西而不是我的web.config?

此外,这不是使用SSL。

WCF配置:

  

    <services>
    <service name="DSLDService.DSLDService">
    <endpoint binding="basicHttpBinding" bindingConfiguration=""
    contract="DSLDService.IDocument" />
    </service>
    </services>
  

Web应用程序配置:

  

    <endpoint address="http://xxx/DSLDService/DSLDService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocument"
    contract="DSLDServiceReference.IDocument" name="" />
  

  

    <binding name="BasicHttpBinding_IDocument" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="2147483647"    maxBufferSize="2147483647"
    maxReceivedMessageSize="2147483647" useDefaultWebProxy="true">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
    </binding>
  

感谢。

1 个答案:

答案 0 :(得分:1)

您需要为您的服务以及客户端(现在就是您所拥有的)配置绑定配置,您可以在其中定义最大大小,否则默认为64 kb。