我使用C#将数据发布到IIS Web服务器。
我使用了XML和模式,并且在一个字段中发布了很长的数据时,我收到了“错误请求错误”。 例如,
<Field1>TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT.......<Field1>
我已经修改了我的Web.Config
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836" ></standardEndpoint>
</webHttpEndpoint>
我需要做些什么来使这项工作?
<system.web>
<authentication mode="Forms" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<httpRuntime maxRequestLength="204800" executionTimeout="12000" requestValidationMode="2.0" requestPathInvalidCharacters="" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836"></standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
答案 0 :(得分:1)
您需要在web.config中为所有请求修复此值,而不仅仅是为WCF服务修复此值...
<httpRuntime maxRequestLength="1234" executionTimeout="1200" />
你可能需要增加这个数字。这是针对首先发生的HttpRuntime - 所有请求都受此标记定义的规则约束。您为WCF服务设置的请求限制仅在请求首先通过此检查(和其他)时才会应用。
答案 1 :(得分:0)
我通过将readerQuotas添加到standardEndpoint
来修复它<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="21474836" maxBufferSize="21474836" maxBufferPoolSize="21474836" >
<readerQuotas maxStringContentLength="2048000" maxArrayLength="2048000" maxDepth ="65000"/>
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>