尝试上传大文件时出现异常

2023-12-07

我正在为我的服务使用 wshttpbinding

<wsHttpBinding>
            <binding name="wsHttpBinding_Windows" maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="2147483647">
                <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="Message">
                    <message clientCredentialType="Windows"/>
                </security>
            </binding>
        </wsHttpBinding>

<behavior name="ServiceBehavior">
                <dataContractSerializer  maxItemsInObjectGraph="6553600"/>
                <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647"/>
            </behavior>

当我尝试上传 15Mb 的文件时,它会抛出以下 EndPointNotFoundException:

异常消息:

There was no endpoint listening at "MY SERVICE URL" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

例外:

The remote server returned an error: (404) Not Found.

有 (2) 个设置maxRequestLength and maxAllowedContentLength在 WCF 配置的服务器端,您需要增加该配置才能解决此异常。在 WCF 服务服务器端的 .config 中,确保添加以下内容:

<system.web>
  <!--Increase 'maxRequestLength' to needed value: 100mb (value is in kilobytes)-->
  <httpRuntime maxRequestLength="102400"/>
</system.web>

<system.webServer>
  <security>
    <requestFiltering>
      <!--Increase 'maxAllowedContentLength' to needed value: 100mb (value is in bytes)-->
      <requestLimits maxAllowedContentLength="104857600" />
    </requestFiltering>
  </security>
</system.webServer>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试上传大文件时出现异常 的相关文章

随机推荐