Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json ';System.OutOfMemoryException';加载大容量数据时引发_Json_Asp.net Mvc_Kendo Grid - Fatal编程技术网

Json ';System.OutOfMemoryException';加载大容量数据时引发

Json ';System.OutOfMemoryException';加载大容量数据时引发,json,asp.net-mvc,kendo-grid,Json,Asp.net Mvc,Kendo Grid,当我加载100000行20列intp剑道网格时,我得到了500个错误 所以我检查了json的响应,将内存从异常中释放出来。这是下面的代码 In the webconfig,have set <system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="500000000

当我加载100000行20列intp剑道网格时,我得到了500个错误

所以我检查了json的响应,将内存从异常中释放出来。这是下面的代码

    In the webconfig,have set   

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




    This is the mvc controller.



  public JsonResult JqueryKendoGridVirtualScrolling()
                {

                    using (var s = new KendoEntities())
                    {
                        var x = s.premiumsbytreaties.ToList().Take(100000);

                        if (x != null)
                        {
                            var jsonResult = Json(x, JsonRequestBehavior.AllowGet);

                            jsonResult.MaxJsonLength = int.MaxValue;
                            return jsonResult;
                            //return Json(x.ToList(), JsonRequestBehavior.AllowGet);
                        }

                        else
                        {

                            return null;
                        }
                    };


                }

It is working fine for 6 columns.But not working for 15 columns.
在网络配置中,已设置
这是mvc控制器。
公共JsonResult JqueryKendoGridVirtualScrolling()
{
使用(var s=new KendoEntities())
{
var x=s.premiumsbytreaties.ToList().Take(100000);
如果(x!=null)
{
var jsonResult=Json(x,JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength=int.MaxValue;
返回jsonResult;
//返回Json(x.ToList(),JsonRequestBehavior.AllowGet);
}
其他的
{
返回null;
}
};
}
它可以在6列中正常工作,但不能在15列中正常工作。
工作良好,记录为20万条,见输出

这里有两个问题:

  • 500000000个字符对于HTTP响应的JSON内容太长。这将需要时间通过网络,也就是在客户端浏览器能够解析和处理数据之前(需要时间和内存)

    其中1%还是太多了

  • 您没有使用剑道对“”的支持

    在他们的示例中,操作的第一个参数是
    [DataSourceRequest]DataSourceRequest
    ,然后在创建响应时使用该参数(使用
    ToDataSource
    扩展方法)

    与支持剑道网格(和其他控件)的AJAX方法类似 它们一起工作以传递分页、排序和筛选参数以及 在返回数据之前应用于该数据

    如果您的数据是适合db提供商的
    IQueryable
    ,则 发生在数据库上


  • 100000行15列-您希望得到什么。(一个用户怎么可能吸收这么多的信息。使用分页机制查看堆栈跟踪我怀疑Kendo使用的JSON序列化内部的某些东西超过了2GB对象大小限制.NET。下载了这么大的文件,你的站点即使在局域网上也无法使用。@Stephen Muecke我的要求是他们不需要“我不需要分页,所以我使用了下面的剑道网格技术,但mvc响应本身我遇到了一个错误。实现延迟加载,从服务器按需加载,请参阅demo.telerik.com/kendo-ui/grid/virtualization-remote-data。有时您必须告诉客户/经理他们的要求不可行。