IIS 7.5托管的WCF服务在处理大请求时抛出EndpointNotFoundException和404错误。

8
我有一个WCF REST服务,托管在IIS 7.5 Windows 2008 R2上。该服务的工作正常,除非客户端试图发送大于约25 MB的消息。具体来说,当发送大小为约25 MB的消息时,服务可以正确接收和处理消息;当发送大小为约31 MB的消息时,服务将失败。
在VS 2010本地托管时,消息会被成功接收而不会出现错误。但是,在远程IIS 7.5上托管时,服务立即响应:"System.ServiceModel.EndpointNotFoundException:没有侦听地址...",内部异常是:"远程服务器返回了一个错误:(404)未找到"。
这与最大消息大小设置不足引发的异常不同。考虑到本地托管时没有出现错误,我的猜测是它与IIS或某些防火墙设置有关。
以下是配置内容:
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime requestPathInvalidCharacters="" maxRequestLength="512000"/>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
    <bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="524288000" maxBufferSize="524288000">
          <readerQuotas maxStringContentLength="524288000" maxArrayLength="524288000"/>
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>
2个回答

14

这是IIS的最大上传大小问题,它的默认值为30MB。你可以在web.config中修复它:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="524288000"/>
        </requestFiltering>
     </security>
</system.webServer>

你也可以在IIS管理器中更改它,位于请求筛选 / 功能设置的某个位置。需要修复的值是“最大允许内容长度(字节)”。


0

你可以尝试将最大值设置为int max,即2147483648,如果超出这个范围,你可能需要考虑拆分上传或流式传输。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接