Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF Rest 400错误请求图像大小_C#_Visual Studio 2010_Wcf - Fatal编程技术网

C# WCF Rest 400错误请求图像大小

C# WCF Rest 400错误请求图像大小,c#,visual-studio-2010,wcf,C#,Visual Studio 2010,Wcf,我到处寻找,尝试了所有的解决方案,但似乎没有什么对我有效。 上传大于64k的图像时,我收到了错误的400请求。 它正在工作,然后突然停止工作。没有代码更改或配置文件更改。 还有什么会影响配置文件设置? 这是我的配置文件 <system.web> <customErrors mode="Off"/> <compilation debug="true" targetFramework="4.0" /> <httpRuntime max

我到处寻找,尝试了所有的解决方案,但似乎没有什么对我有效。 上传大于64k的图像时,我收到了错误的400请求。 它正在工作,然后突然停止工作。没有代码更改或配置文件更改。 还有什么会影响配置文件设置? 这是我的配置文件

<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="webHttpBehavior" name="EzFindWCFService.EZFindWebService">
        <endpoint address="" behaviorConfiguration="EzFindWCFService.EZFindWebServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="EzFindWCFService.EZFindWebService" />
      </service>
    </services>
    <behaviors>



      <endpointBehaviors>
        <behavior name="EzFindWCFService.EZFindWebServiceAspNetAjaxBehavior">
          <!--<enableWebScript />-->
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="webHttpBehavior">          
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>

      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />

    <bindings>
      <basicHttpBinding>
        <binding name="webHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00"
          receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false"
          bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="64" 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>

  </system.serviceModel>

在system.serviceModel/services/service中,您将绑定设置为“webHttpBinding”,但未定义绑定配置。 问题是您没有在system.serviceModel/bindings中设置webHttpBinding。您设置了basicHttpBinding并将其名称设置为webHttpBinding!因此,实际上没有使用这个完整的绑定,因为您的服务元素查找默认的webHttpBinding(因为您没有定义bindingConfiguration),而不是名为webHttpBinding的basicHttpBinding!这就是为什么上传大于64k的文件失败的原因。因为这将超过默认的64k配额。 我希望您理解我:)混合默认绑定名称非常容易出错;)

更新:

此system.serviceModel部分应在以下情况下工作:


我省略了一些默认设置(例如绑定/安全性),以使配置更加精简。
还有一件事:我会小心地将所有配额设置为Int32.MaxValue。测试可能没问题,但在投入生产时请记住将这些值设置为较低。

共享您的web服务
web.config
文件感谢您的关注。所以我所要做的就是换成?那么一切都应该工作?请修改我的配置文件,你看到错误的信息。非常感谢你的帮助。
<services>
  <service name="EzFindWCFService.EZFindWebService" 
           behaviorConfiguration="webHttpBehavior" >
    <endpoint address="" 
              binding="webHttpBinding" bindingConfiguration="ConfigWebHttp"
              behaviorConfiguration="EzFindWCFService.EZFindWebServiceAspNetAjaxBehavior"
              contract="EzFindWCFService.EZFindWebService" />
  </service>
</services>

<behaviors>
  <endpointBehaviors>
    <behavior name="EzFindWCFService.EZFindWebServiceAspNetAjaxBehavior">
      <!--<enableWebScript />-->
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="webHttpBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <webHttpBinding>
    <binding name="ConfigWebHttp"
             openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:05:00"
             maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
</bindings>