Error The length of the string exceeds the value set on the maxJsonLength property

可紊 提交于 2019-11-30 11:50:00

问题


I am currently have a grid with PDF attachment. Each PDF can have file size up to 1MB. The problem is I am getting the value "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"

I already placed the following in the web.config but the problem is it works only if the Kendo UI Grid needs to display 6 records.

<system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength = "2147483647"></jsonSerialization>
      </webServices>
    </scripting>
</system.web.extensions>

回答1:


Based on the following link:

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

public ActionResult SomeControllerAction()
{
  var jsonResult = Json(veryLargeCollection, JsonRequestBehavior.AllowGet);
  jsonResult.MaxJsonLength = int.MaxValue;
  return jsonResult;
}


来源:https://stackoverflow.com/questions/16848289/error-the-length-of-the-string-exceeds-the-value-set-on-the-maxjsonlength-proper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!