30

我目前有一个带有 PDF 附件的网格。每个 PDF 的文件大小最大为 1MB。问题是我得到值“使用 JSON JavaScriptSerializer 进行序列化或反序列化期间出错。字符串的长度超过了 maxJsonLength 属性上设置的值

我已经在 web.config 中放置了以下内容,但问题是它仅在 Kendo UI Grid 需要显示 6 条记录时才有效。

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

1 回答 1

74

基于以下链接:

JavaScriptSerializer 期间 ASP.NET MVC 中的 MaxJsonLength 异常

public ActionResult SomeControllerAction()
{
  var jsonResult = Json(veryLargeCollection, JsonRequestBehavior.AllowGet);
  jsonResult.MaxJsonLength = int.MaxValue;
  return jsonResult;
}
于 2013-06-03T00:03:42.803 回答