How To Set An Unlimited Length For MaxJsonLength In Web.Config

For More Videos Visit Our YouTube Channel




How To Set An Unlimited Length For MaxJsonLength In Web.Config, The Length Of The String Exceeds The Value Set On The MaxJsonLength Property, Error During Serialization Or Deserialization Using The JSON JavaScriptSerializer, InvalidOperationException, JsonSerialization, MaxJsonLength, Int32.MaxValue, JsonResult, 2147483644

We may face this issue, when we use webservice for retrieving huge amount of data. Especially when the output is JsonResult. Lets start with a simple example.

How To Set An Unlimited Length For MaxJsonLength In Web.Config, The Length Of The String Exceeds The Value Set On The MaxJsonLength Property, Error During Serialization Or Deserialization Using The JSON JavaScriptSerializer, InvalidOperationException, JsonSerialization, MaxJsonLength, Int32.MaxValue, JsonResult, 2147483644

How To Set An Unlimited Length For MaxJsonLength In Web.Config, The Length Of The String Exceeds The Value Set On The MaxJsonLength Property, Error During Serialization Or Deserialization Using The JSON JavaScriptSerializer, InvalidOperationException, JsonSerialization, MaxJsonLength, Int32.MaxValue, JsonResult, 2147483644

In the given example, we are using Jquery ajax call for getting data from server. Here we are trying to get the list of string of size 16000. Normally, we would definitely get the the error.



There is a limit for transferring data using Webservices. If that limit exceeds, we will get this error. In order to Resolve this issue, we have to increase the limit to its maximum.



How To Set An Unlimited Length For MaxJsonLength In Web.Config, The Length Of The String Exceeds The Value Set On The MaxJsonLength Property, Error During Serialization Or Deserialization Using The JSON JavaScriptSerializer, InvalidOperationException, JsonSerialization, MaxJsonLength, Int32.MaxValue, JsonResult, 2147483644

On the web.config file, we have to increase the maxJsonLength of jsonSerialization property. The Maximum value is 2147483644 (Int32.MaxValue). By this way, we can resolve this issue.