错误字符串的长度超过了在maxJsonLength属性上设置的值 [英] Error The length of the string exceeds the value set on the maxJsonLength property

查看:556
本文介绍了错误字符串的长度超过了在maxJsonLength属性上设置的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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"

我已经在web.config中放置了以下内容,但问题是,只有在Kendo UI网格需要显示6条记录的情况下,它才起作用.

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>

推荐答案

基于以下链接:

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

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

这篇关于错误字符串的长度超过了在maxJsonLength属性上设置的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆