在WCF WebApi(预览版6)中,许多WCF绑定属性已移至配置类中。例如:
var config = new HttpConfiguration {MaxReceivedMessageSize = 250001};
<readerQuotas>
的相应设置是什么?例如,我如何设置如下配置:
<binding name="largeLimits" maxReceivedMessageSize="250001">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
答案 0 :(得分:2)
ReaderQuotas
属性与SOAP消息的处理特别相关;根据MSDN,此属性定义“可以由端点处理的SOAP消息的复杂性的约束”。但是,Web API与SOAP无关,因此该设置对它没有意义。
另一方面,使用XmlMediaTypeFormatter
时,此配额可能有意义,但似乎使用XmlDictionaryReaderQuotas.Max
(请参阅http://wcf.codeplex.com/SourceControl/changeset/view/ee192ebdfb80#WCFWebApi%2fsrc%2fMicrosoft.Net.Http.Formatting%2fSystem%2fNet%2fHttp%2fFormatting%2fXmlMediaTypeFormatter.cs)