Fix JSON serialization error by setting maxJsonLength.
This error is occured when serialize an object in JSON string by JavaScriptSerializer class, it will throw this exception if object contains too many records(data). We can fix this issue by setting maxJsonLength in web.config file.
Exception type: InvalidOperationException
Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration> .