【发布时间】:2015-11-22 04:40:18
【问题描述】:
我正在使用 .net Web Api 为我的数据网格获取数据。调用是通过这样的ajax调用进行的
$.ajax({
type: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: ReportURL, // "api/AppData/InvoiceReport/10"
success: function (mydata) {
console.log(mydata);
createReportGrid(myData); // this function creates a KENDO grid
},
error: function (error) {
alert(error);
}
});
Web API 方法如下所示
[HttpGet]
public HttpResponseMessage InvoiceReport(int Id)
{
// some llogic of data retrieving
// objReportDataList is of Type List<vmReport>
// thisstructure contains a DataTable, and 2 more list type
return Request.CreateResponse(HttpStatusCode.OK, objReportDataList);
}
对于大约 100K 行的行数,这些调用完美工作
Web Api 完美序列化。但是当行数超过 200K 我得到 500 internal server error 堆栈跟踪告诉“System-OutOfMemoryException-occured-in-mscorlib-dll”
注意 - 我不能使用服务器分页来仅获取少量数据。这百万行数据正在处理 ASP.NET Webforms 应用程序。我们已经迁移到 MVC 模式并使用 WebApi 来获取数据,但是发生了这个错误。 PS - 我尝试了许多解决方案,但无能为力
请指导我删除此错误并开始我的报告
【问题讨论】:
-
检查 webforms 解决方案的 Web.config。我敢打赌那里有一个设置。这听起来像一个配置问题。除了你已经知道的大量数据之外。
-
我怀疑 web.config 是否有任何设置可以避免内存不足错误...尽管我可能是错的。
-
web.config 设置了 json 限制......我正在使用 JSON.NET 序列化对象。我知道的数据很多。当它可以产生 20 万条记录时,为什么不进一步呢??
-
我们能否了解如何从 Web Api 流式传输这些大数据?
标签: ajax json asp.net-mvc asp.net-web-api serialization