I'm getting the following exception when returning a large JSON result:
The length of the string exceeds the value set on the maxJsonLength property.
I am trying to catch the exception where the serialisation happens but this does not happen.
try
{
return new JsonResult()
{
Data = LargeJsonData,
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
catch (Exception)
{
return "Error";
}
I do NOT want the adjust the property. I just want to catch the exception and handle appropriately.
I have found the following question which seems like a duplicate, but the accepted answer modifies the maxJsonLength property.
How to catch error during serialization or deserialization using the JSON JavaScriptSerializer
Thanks, Steve