asp.net-mvc - mvc Controller 中 JsonResult 的最大大小是多少

标签 asp.net-mvc asp.net-mvc-4 asp.net-mvc-3 razor

我必须使用基于 Angular 的应用程序来处理 MVC,我必须从数据库中检索 2000 万条数据以使用 Angular 发送。

如果我从 json 发送低于 13000 个数据返回,则返回错误。 否则会出现此错误。

所以使用了下面的解决方案,它工作正常,但是为什么必须使用这个,JSON结果的大小限制是多少。

  var jsonResult = Json(x, JsonRequestBehavior.AllowGet);

                    jsonResult.MaxJsonLength = int.MaxValue;
                    return jsonResult;

JsonResult 的数据大小的最大大小是多少?

enter image description here

最佳答案

如果你用另一种方式编写它,你的错误就会消失:

return new JsonResult()
{
    Data = x,
    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
    MaxJsonLength = Int32.MaxValue
};

关于asp.net-mvc - mvc Controller 中 JsonResult 的最大大小是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42116613/

相关文章:

asp.net - Yahoo.Yui.Compressor.Build.MsBuild.dll。无法加载文件或程序集“Yahoo.Yui.Compressor”

javascript - 在 .NET core MVC 应用程序中包含带 @ 符号的 Javascript 库

asp.net-mvc-4 - 自定义 DotnetOpenauth Paypal 客户端( key 不存在)

c# - TempData 在 RedirectToAction 期间未结转

jquery - 显示:none fields not being posted to controller

JavaScript 链接无法正常工作

c# - 我如何迭代 Asp.net MVC3 中的项目

c# - 为什么 Visual Studio 没有选择我的类库?

ASP.NET 4 WebAPI : route with back slash

jquery - asp.net mvc3 文本区域的水印