JsonResult or Json: which to use?

Viewed 4205

In ASP.NET MVC 3, which is more correct to use: Json() or new JsonResult()? Either returns the same result. Thanks for helping solve an office debate.

2 Answers

If you a returning a large dataset as a data source for grid or other UI controls via Ajax, sometimes if this dataset is over 1000 records UI controls will not bind because of maximum Json length is not specified.

So instead of return Json(data) you can do this: return new JsonResult(Data = data, MaxJsonLength = 50000);

Related