"Message Length Exceeded" with ASP.NET AJAX

Have you gotten a client side message along the lines of "Message Length Exceeded" when working with an ASP.NET AJAX application?  If so, check into the web.config tag:

<jsonSerialization maxJsonLength="........"> 

Depending on the payload that you are  trying to send to the client, you may need touncomment this line and put a large enough value in for the maxJsonLength attribute.  I would suggest caution in doing this.  By setting this value to a really high number, you can solve the problem, but you can cause problems on the client if the payload is too large instea od just generating the error.  As we do more development, I am finding that browsers are fickle apps and can be fairly easily overwhelmed by too much data.  I am sure that no one is surprised by that.

For more information on maxJsonLegnth, check out:

http://ajax.asp.net/docs/mref/P_System_Web_Configuration_ScriptingJsonSerializationSection_MaxJsonLength.aspx 

http://ajax.asp.net/docs/mref/P_System_Web_Script_Serialization_JavaScriptSerializer_MaxJsonLength.aspx 

1 Comment

  • "I am finding that browsers are fickle apps and can be fairly easily overwhelmed by too much data".

    I agree on that, for example I've used IE to browse several web site pages which contain a whole bunch of information including several Flash animations, javascript code for user interactions, iframes, etc. I've seen that the browser has a really hard time with too much info in a single page.

Comments have been disabled for this content.