我正在使用 C# 将数据发布到 IIS 网络服务器。
我使用了 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>
最佳答案
您需要在 web.config 中为所有请求修复此值,而不仅仅是 WCF 服务,正如您所做的那样...
<httpRuntime maxRequestLength="1234" executionTimeout="1200" />
您可能需要增加该数字。这是针对首先发生的 HttpRuntime - 所有请求都受此标记定义的规则的约束。您为 WCF 服务设置的请求限制只有在请求首先通过此检查(和其他检查)时才会应用。
关于c# - 如何增加 Http Post 中的项目大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16448223/