Json set max length

Im working with asp.net MVC3. I am using the Newtonsoft.Json.JsonConvert.SerializeObject method to parse a json object. Im Im getting the error "An error occurred while serializing or deserializing using the JSON JavaScriptSerializer. The string length exceeds the value set in the maxJsonLength property."

I also tried setting in web.config to the maximum length. But, there is no benefit.

Please help me.

thanks

+4
source share
2 answers

Try the following steps at this URL. This is mainly because the size of the Json response object is too large and exceeds the maximum size.

http://www.smartdigitizers.com/net-development-tips/error-during-serialization-or-deserialization-using-the-json-javascriptserializer/

+1
source

On your controller, return your json as follows:

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

You can change MaxJsonLength to suit your needs.

0
source

Source: https://habr.com/ru/post/1438177/


All Articles