Solve jQuery Ajax Error "The Length of the String Exceeds the Value Set on the Max jsonlength Property" in Asp.net

Introduction:
This article explain you how to solve the problem of “Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.” in asp.net 
Description:
Below code is used to solve the problem “Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.”

Generally this problem occur whenever our json result set length exceeds default json MaxJsonLength property value. By default MaxJsonLength property will allow 102400 (100k) in case our string exceeding this length we will get JavaScriptSerializer error.
To implement this we need to write the code like as shown below  in web.config file

Web.Config

Open web.congig file  and set the maxJsonLength to maximum as shown below to solve the error.


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

No comments:

Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks