【问题标题】:Error The length of the string exceeds the value set on the maxJsonLength property错误 字符串长度超过 maxJsonLength 属性设置的值
【发布时间】:2013-05-26 17:51:22
【问题描述】:

我目前有一个带有 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>

【问题讨论】:

标签: json kendo-grid


【解决方案1】:

基于以下链接:

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

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

【讨论】:

  • 如果他们在配置文件中进行设置这样就不必在这里添加额外的代码了。谢谢!
  • 您好!在这里,当我在 json 中发布长度超过 600 的数组列表的请求时,出现超出最大长度的错误。我正在将所有数据传递给控制器​​。
猜你喜欢
  • 2012-08-06
  • 2018-04-25
  • 2017-08-31
  • 1970-01-01
  • 2015-03-27
  • 2015-04-06
  • 2015-05-30
  • 2016-02-11
  • 1970-01-01
相关资源
最近更新 更多