Friday, August 15, 2008

JSonSerialization Error Solution

Sometime when working with ScriptSevice and ScriptMethod in webservice following error may occur.

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

Reason for this is JavaScript Serialization setting . This allow maximum 2097152 character by default. It method return string larger then this then it throw above error.

Solution for this is to put following configuration in web.config file.

<jsonSerialization maxJsonLength="500000"></jsonSerialization>

In above configuration instead you can set maxJsonLength to certain value so it allow larger string.

Maximum value for that field is 2147483647 as this property is System.Int32.

More information you can find it on following location.


Anonymous said...

Just what I needed. Thanks!

Anonymous said...

Thanks for this. Hit the same problem

skh said...


Anonymous said...

thanks buddy, its really helpful :)