I have a ASP.NET project, with some AJAX calling a webmethod, that would return JSON.
If the DataSet
has about 100 lines, there is no problem. But with 1000 lines, it launch the error:
Error during serialization or deserialization using JSON JavaScriptSerializer. The size of the string exceeds the value set in the maxJsonLength property
[WebMethod(EnableSession = true)]
public static string PublicWebMethod()
{
DataSet ds = new DataSet(); // in the reality do a mountrous query
if (ds.Tables[0].Rows.Count > 0)
{
return JsonConvert.SerializeObject(clsUtil.ToArray(ds.Tables[0]));
}
else
{
return "false";
}
}
}
How can I solve this by setting a configuration in the method?
I don't want to change the web.config