jleach
jleach

Reputation: 7790

JSON JavaScriptSerializer maxJsonLength exception (but very small payload)

I'm having an intermittent issue in MVC5 with the JSON parser throwing a System.InvalidOperationException:

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Straight forward enough, but when I look at the request details, I have no idea why this would happen as the payload is very small:

(not sure how to scrape a raw request from chrome debugger, so): enter image description here

The response is straightforward enough: enter image description here

Any ideas on something a little less normal that might be causing this?

Upvotes: 1

Views: 181

Answers (1)

jleach
jleach

Reputation: 7790

The problem was not in the size of the JSON request, but rather in the size of the JSON response.

return Json(model);

This the model was too large, and that's where the exception was coming from (why this wasn't raising in debug instance or logging the exception I'll have to look into...)

Upvotes: 1

Related Questions