【发布时间】:2013-05-08 19:00:27
【问题描述】:
我正在使用 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>
【问题讨论】:
-
如果您使用 JavaScript 将其发布回来,请确保您的 web.config 设置为接受大型 json blob。 The JSON request was too large to be deserialized
-
我正在使用 C# 客户端和 XML
-
请求正文到底有多大(使用 Fiddler 轻松获取该数字)。
-
您在 Field1 的结束标记中缺少 / - 会不会这么简单?
-
不,这只是一个错字,我使用 XmlDocument 创建 XML
标签: c# asp.net rest iis http-post