Error: The length of the string exceeds the value set on the maxJsonLength property

Ajax scenarios are meant only for small to medium server side calls not for getting tons of data, and if you are getting a lot of data using the asynchronous request then you are asking for trouble.

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

The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k). You can set the MaxJsonLength property on your web.config:

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration>

Add a Comment

Your email address will not be published. Required fields are marked *