我已经搜遍了所有的解决方案,但似乎没有什么对我有用。 上传大于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>
答案 0 :(得分:0)
在system.serviceModel / services / service中,您将绑定设置为“webHttpBinding”,但是您没有定义bindingConfiguration。 问题是您没有在system.serviceModel / bindings中设置webHttpBinding。您设置了basicHttpBinding并将其名称设置为webHttpBinding!所以实际上没有使用这个完整的绑定,因为你的service-element查找默认值(因为你没有定义bindingConfiguration)webHttpBinding,而不是查找名为webHttpBinding的basicHttpBinding!这就是为什么您的上传文件因大于64k的文件而失败的原因。因为这会超过默认配额64k。 我希望你理解我:)混合默认绑定名称非常容易出错;)
<强>更新强>
这个system.serviceModel-Section应该可以工作:
<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>
我省略了一些默认设置(例如绑定/安全性)以使配置更加苗条。 还有一件事:我要小心设置Int32.MaxValue的所有配额。测试可能没问题,但是在投入生产时请记住将这些值设置下来。