1
votes

I realize this question has been asked "dozens of times"

https://stackoverflow.com/search?q=maxStringContentLength

However, I still have not found a solution that matches my needs. I have an MVC3 app connecting to a REST app which was build in WCF 4.0.

So far I have...

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"  />
  </webHttpEndpoint>
</standardEndpoints>

The REST server part works. It allows me to pass in a large model with a long string value as one of it's properties. I verified that from my MVC app as I posted the model with the large bit of data, and saw that the data made it in the DB.

When the app finished the post and tried to request the data it had just saved, I get the infamous error when it tries to serialize my model...

The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

I tried many things such as

<bindings>
  <webHttpBinding>
    <binding>
      <readerQuotas maxStringContentLength="2147483647"/>
    </binding>
  </webHttpBinding>
</bindings>

I am retrieving the rest data by using the WebChannelFactory and then creating a channel to the interface.

string uri = "http://localhost/RestService";
WebChannelFactory<IRestService> _cf = new WebChannelFactory<IRestService>(new Uri(uri));
IRestService service = _cf.CreateChannel();

But nothing as worked so far. Is there something I am missing in my MVC3 app that will allow the model to be serialized correctly?

I know with WCF 4 there is no .svc file, and no bindings and such, but I am at a loss as to what I need to throw in the MVC app to allow the default configuration of REST to be changed.

1

1 Answers

1
votes

Look at the code in the answer to this question to see how to see the max string length is set. Seems like that approach would work for you.