【问题标题】:Getting Exception when trying to upload a big files size尝试上传大文件时出现异常
【发布时间】:2011-09-17 01:17:42
【问题描述】:

我正在为我的服务使用 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.

【问题讨论】:

  • 上传较小的文件是否有效?
  • &lt;endpoint&gt;部分验证端点的IP地址和端口
  • 是的,它上传的尺寸较小。还有一件事我正在使用异步调用(如果重要的话)。

标签: c# wcf large-files payload


【解决方案1】:

您的 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>

【讨论】:

    【解决方案2】:

    上传限制设置为 2 级,第 1 级由应用程序设置,第 2 级由服务器设置。

    我觉得你的应用配置不错。

    检查您在 machine.config 文件中定义的 IIS 设置。 我找到了一个Microsoft KB article 来配置这个

    您可以在任何这些位置配置值。

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 2016-01-23
      • 1970-01-01
      • 2014-03-04
      • 2014-03-04
      • 2011-02-02
      • 2013-05-30
      相关资源
      最近更新 更多