'json set Max length

Im working with asp .net MVC3 . I'm using Newtonsoft.Json.JsonConvert.SerializeObject method for parsing json object . Im Im getting Error "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."

I have also tried settings in web.config to max length . But ,No gain.

Kindly assist me .

Thanks



Solution 1:[1]

On your controller, return your json like this:

var result = //your data;
var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;

You can change the MaxJsonLength according to your needs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jude Duran