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

Gab*_*aby 2 c# wcf payload large-files

我正在使用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>
Run Code Online (Sandbox Code Playgroud)

当我尝试上传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.
Run Code Online (Sandbox Code Playgroud)

例外:

The remote server returned an error: (404) Not Found.
Run Code Online (Sandbox Code Playgroud)

atc*_*way 15

有(2)个设置maxRequestLength,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>
Run Code Online (Sandbox Code Playgroud)