ReaderQuota Settings in WCF WebApi

383 Views Asked by At

In WCF WebApi (Preview 6), Many of the WCF binding attributes have been moved into the configuration class. For example:

var config = new HttpConfiguration {MaxReceivedMessageSize = 250001};

What are the corresponding settings for <readerQuotas>? For example, how would I setup a configuration like:

    <binding name="largeLimits" maxReceivedMessageSize="250001">
      <readerQuotas maxStringContentLength="2147483647"/>
    </binding>
1

There are 1 best solutions below

1
On

The ReaderQuotas property is specifically related to the processing of SOAP messages; according to MSDN, this property defines "constraints on the complexity of SOAP messages that can be processed by endpoints". However, Web API is not tied to SOAP, so this setting doesn't makes sense for it.

On the other hand, this quota could make sense when using the XmlMediaTypeFormatter, however it appears to be using XmlDictionaryReaderQuotas.Max (see http://wcf.codeplex.com/SourceControl/changeset/view/ee192ebdfb80#WCFWebApi%2fsrc%2fMicrosoft.Net.Http.Formatting%2fSystem%2fNet%2fHttp%2fFormatting%2fXmlMediaTypeFormatter.cs)