尝试上传大文件时获取异常

时间:2011-06-17 09:34:40

标签: 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.

例外:

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

2 个答案:

答案 0 :(得分:15)

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

答案 1 :(得分:1)

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

您的应用配置对我来说很好。

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

您可以在以下任何位置配置值。