C# 远程服务器在流传输时返回了意外响应:(400)错误请求

C# 远程服务器在流传输时返回了意外响应:(400)错误请求,c#,wcf,iis,streaming,C#,Wcf,Iis,Streaming,我在流媒体方面有问题。当我发送小文件(如1kb txt)时,一切正常,但当我发送大文件(如100KB jpg或2gb psd)时,我得到: The remote server returned an unexpected response: (400) Bad Request. 我正在使用Windows7、VS2010和.NET3.5以及WCF服务库 我失去了整个周末的时间,我仍然看到这个错误:/请帮助我 客户: var client = new WpfApplication1.Servic

我在流媒体方面有问题。当我发送小文件(如1kb txt)时,一切正常,但当我发送大文件(如100KB jpg或2gb psd)时,我得到:

The remote server returned an unexpected response: (400) Bad Request.
我正在使用Windows7、VS2010和.NET3.5以及WCF服务库

我失去了整个周末的时间,我仍然看到这个错误:/请帮助我

客户:

 var client = new WpfApplication1.ServiceReference1.Service1Client("WSHttpBinding_IService1");

        client.GetString("test");
        string filename = @"d:\test.jpg";
        FileStream fs = new FileStream(filename, FileMode.Open);
        try
        {
            client.ProcessStreamFromClient(fs);
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception);
        }
app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="StreamedHttp" closeTimeout="10:01:00" openTimeout="10:01:00"
          receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false"
          bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536000" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
          useDefaultWebProxy="true">

          <readerQuotas maxDepth="0" maxStringContentLength="0" maxArrayLength="0"
          maxBytesPerRead="0" maxNameTableCharCount="0" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/"
        binding="basicHttpBinding" bindingConfiguration="StreamedHttp"
        contract="ServiceReference1.IService1" name="WSHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>
App.config

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

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Binding1"
                 hostNameComparisonMode="StrongWildcard"


                 maxBufferSize="65536000"

                 transferMode="Streamed"

                 bypassProxyOnLocal="false"

                 closeTimeout="10:01:00"

openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"

maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <security mode="None" />
        </binding>
      </basicHttpBinding>

    </bindings>
    <client />
    <services>
      <service name="WcfServiceLibrary2.Service1">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/"   />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address=""  binding="basicHttpBinding" contract="WcfServiceLibrary2.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->

          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

尝试设置:

<serviceDebug includeExceptionDetailInFaults="true" /> 

它不会解决问题,但您可能会收到一条错误消息,说明问题所在。

尝试设置:

<serviceDebug includeExceptionDetailInFaults="true" /> 


它不会解决问题,但您可能会收到一条错误消息,说明问题所在。

以下是错误:public void ProcessStreamFromClient(System.IO.Stream Stream){base.Channel.ProcessStreamFromClient(Stream);如果我的webmethod为空,则仍会出现错误。是否有任何ideaTry发送一个小文件并检查它是否仍然有效,然后尝试逐渐增大文件大小以找到限制所在。这标记为答案,但没有解释实际解决方案。错误如下:public void ProcessStreamFromClient(System.IO.Stream Stream){base.Channel.ProcessStreamFromClient(Stream);如果我的webmethod为空,仍然会出错。您是否有任何ideaTry发送一个小文件并检查它是否仍然有效,然后尝试逐渐增大文件大小以找到限制所在。这标记为答案,但没有解释实际解决方案。