2

我正在使用 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>
4

2 回答 2

1

您需要在 web.config 中为所有请求修复此值,而不仅仅是 WCF 服务,就像您所做的那样......

<httpRuntime maxRequestLength="1234" executionTimeout="1200" />

您可能需要增加该数字。这是针对首先发生的 HttpRuntime - 所有请求都受此标记定义的规则的约束。仅当请求首先通过此检查(和其他检查)时,才会应用您为 WCF 服务设置的请求限制。

于 2013-05-08T21:02:29.693 回答
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>
于 2013-05-09T11:06:38.983 回答