我有一个控制台应用程序可以将文件发送到我的 WCF 服务,但是当我尝试发送大于 4MB 的文件时,我的服务响应 502 http 代码(代理错误 - 指定的网络名称不再可用。)。这段代码对我来说没有意义,因为他接受小于 4MB 的文件。
WCF 服务在 Windows 2003 Server、IIS 6 和如下配置文件下运行。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="FileUploadServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="FileUploadServiceBinding"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="67108864" maxBufferSize="65536"
closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:05:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="FileUploadServiceBehavior" name="MyProject.ServiceFileTransfer.FileUploadService">
<endpoint address="" binding="basicHttpBinding" contract="MyProject.ServiceFileTransfer.IFileUploadService"
bindingConfiguration="FileUploadServiceBinding">
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
为什么发送大于 4mb 的文件会返回 502 Bad Gateway 错误?