c# - 尝试上传大文件大小时出现异常

标签 c# wcf large-files payload

我正在为我的服务使用 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) 个设置 maxRequestLengthmaxAllowedContentLength,您需要增加这些设置才能解决此异常.在 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/

相关文章:

c# - 在 C# 中处理大文件

c# - 使用 Rhino Mocks 变干

c# - 我们如何在没有动画的情况下显示 hubtile

wcf - 远程证书名称不匹配。名字的问题

image - 网络浏览器中的非常大的图像

smtp - Javamail - 如何处理大附件?

c# - 为遗传算法表示二进制基因组的明智方法是什么?

c# - 如何强制 HttpModule 仅在特定目录上使用?

.net - 使用空或无效的date元素反序列化SOAP响应

WCF 服务方法返回 json 或 soap