WCF RestFull提交数据超出限额解决方法

最近在使用wcf restfull时出现了超大数据提交出错的问题。

服务端会返回错误:服务器处理请求时遇到错误。有关构造有效服务请求的内容,请参阅服务帮助页。异常消息为“反序列化对象 属于类型 YesWayClientAPI.TourRecord.Model.TourRecordSaveTrackRequest 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。”。

lALOIsonHnnNAew_492_121

这时我们可以通过配置web.config来解决这个问题:

在web.config中的<system.serviceModel>节点下添加下面配置项:

<standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint  name="" transferMode="StreamedRequest" helpEnabled="true"  maxReceivedMessageSize="10485760" automaticFormatSelectionEnabled="true"                                  defaultOutgoingResponseFormat="Json" >
          <readerQuotas  maxStringContentLength="8192000" />
        </standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints>
原文地址:https://www.cnblogs.com/learn-dotnet/p/5519162.html