0

Please tell me best way of return max Json result in ASP.NET MVC.

Currently I am using:

return Json(jsonData,JsonRequestBehavior.AllowGet);

In this case, if a method return max size of Json then Ajax throws an error. For this error I use this solution.

var jsonResult = Json(jsonData, JsonRequestBehavior.AllowGet);
jsonResult.maxJsonLength = int.MaxValue;
return jsonResult;

But I have a problem with this solution. If we use this solution, then my response takes more time so please tell me quick and fast solution of this problem.

NightOwl888
  • 55,572
  • 24
  • 139
  • 212

1 Answers1

0

I have solved this kind of problem with SignalR. Basically, 1.Create a SignalR hub 2. In your page JS, connect to the hub and listen for responses, updating your target control from an incoming stream 3. In your controller request, get the connectionid and stream responses as blocks of data.

This way you can send infinite amounts and with immediate response time.

Sentinel
  • 3,582
  • 1
  • 30
  • 44