IIS 7.5托管的WCF服务仅针对大型请求抛出EndpointNotFoundException和404

时间:2011-07-18 17:49:30

标签: wcf iis-7.5

我在IIS 7.5 Windows 2008 R2上托管了WCF REST服务。除非客户端尝试发送大于~25 MB的消息,否则该服务将按预期工作。具体来说,当发送大小约为25 MB的消息时,服务会正确接收并处理消息,当发送大小约为31 MB的消息时,服务失败。

在VS 2010本地托管时,收到的邮件没有错误。在IIS 7.5上远程托管时,服务立即响应:“System.ServiceModel.EndpointNotFoundException:没有端点侦听...”,内部异常是:“远程服务器返回错误:(404)Not Found” 。

这与最大邮件大小设置不足时引发的异常不同。鉴于在本地托管时我没有收到错误,我的猜测是它与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 个答案:

答案 0 :(得分:13)

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

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

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

答案 1 :(得分:0)

您可以尝试将最大值设置为最大值为2147483648,除此之外您可能需要考虑拆分上传或流式传输。