weixin_33725272 2015-08-27 17:04 采纳率: 0%
浏览 181

从Web API获取大型JSON

I am using .net Web Api to get data for my data grid. The call is made via ajax call like this

 $.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);
   }
 });

The Web API method Looks like this

[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);
}

These calls work perfectly for Rows Count approx 100K rows

Web Api serializes perfectly. But when the Row Count exceeds 200K i get 500 internal server error The stack traces tells "System-OutOfMemoryException-occured-in-mscorlib-dll"

NOTE - I cant use server pagination to get little data only. This Million rows data is working on a ASP.NET Webforms application. We have migrated to MVC pattern and used WebApi for fetching Data but this error is occuring. PS - I have tried many many solutions, but helpless

Please Guide me to Get this error removed and my reports get going

</div>
  • 写回答

2条回答 默认 最新

  • weixin_33730836 2015-08-27 17:40
    关注

    you can add below in web.config file

    <configuration> 
       <system.web.extensions>
           <scripting>
               <webServices>
                   <jsonSerialization maxJsonLength="50000000"/>
               </webServices>
           </scripting>
       </system.web.extensions>
    </configuration>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?