(400)传输大文件时出现错误请求

时间:2012-09-12 19:22:43

标签: c# wcf

我在尝试传输大于50kb的文件时遇到同样的问题错误信息是“(400)错误请求”

有人可以告诉我哪里错了吗?

以下代码:

 <?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
  <system.serviceModel> 


    <bindings> 
      <basicHttpBinding> 
        <binding name="BasicHttpBinding_IFileTransfer" closeTimeout="00:10:00" 
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
          messageEncoding="Text"  transferMode="Buffered" 
          useDefaultWebProxy="true"> 
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
          <security mode="None"> 
            <transport clientCredentialType="None" proxyCredentialType="None" 
              realm="" /> 
            <message clientCredentialType="UserName" algorithmSuite="Default" /> 
          </security> 
        </binding> 
      </basicHttpBinding> 
    </bindings> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <client> 

      <endpoint  address="http://localhost:57728/FileTransfer.svc" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IFileTransfer" contract="WCFFileTransfer.IFileTransfer" 
    name="BasicHttpBinding_IFileTransfer" /> 

    </client> 


  </system.serviceModel> 
</configuration> 

1 个答案:

答案 0 :(得分:0)

确保服务器上的web.config具有以下设置:

<system.web>
    <httpRuntime maxRequestLength="2147483647" />
    ....
</system.web>