我正在为我的服务使用 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.
异常(exception):
The remote server returned an error: (404) Not Found.
最佳答案
在您的 WCF 配置的服务器端有 (2) 个设置 maxRequestLength
和 maxAllowedContentLength
,您需要增加这些设置才能解决此异常.在 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>
关于c# - 尝试上传大文件大小时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6383893/