Json ';System.OutOfMemoryException';加载大容量数据时引发
当我加载100000行20列intp剑道网格时,我得到了500个错误 所以我检查了json的响应,将内存从异常中释放出来。这是下面的代码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
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万条,见输出
这里有两个问题:
[DataSourceRequest]DataSourceRequest
,然后在创建响应时使用该参数(使用ToDataSource
扩展方法)
与支持剑道网格(和其他控件)的AJAX方法类似
它们一起工作以传递分页、排序和筛选参数以及
在返回数据之前应用于该数据
如果您的数据是适合db提供商的IQueryable
,则
发生在数据库上100000行15列-您希望得到什么。(一个用户怎么可能吸收这么多的信息。使用分页机制查看堆栈跟踪我怀疑Kendo使用的JSON序列化内部的某些东西超过了2GB对象大小限制.NET。下载了这么大的文件,你的站点即使在局域网上也无法使用。@Stephen Muecke我的要求是他们不需要“我不需要分页,所以我使用了下面的剑道网格技术,但mvc响应本身我遇到了一个错误。实现延迟加载,从服务器按需加载,请参阅demo.telerik.com/kendo-ui/grid/virtualization-remote-data。有时您必须告诉客户/经理他们的要求不可行。