C# JsonResult方法不工作/正在加载

C# JsonResult方法不工作/正在加载,c#,jquery,asp.net,ajax,C#,Jquery,Asp.net,Ajax,我在做辅导 在我的控制器类中,我有 public JsonResult GetAllUser(){ List<database1> allUser = new List<database1>(); using (dbContext1 dc = new dbContext1 ()) { allUser = dc.database1.ToList(); } return new JsonRe

我在做辅导

在我的控制器类中,我有

 public JsonResult GetAllUser(){
    List<database1> allUser = new List<database1>();

    using (dbContext1 dc = new dbContext1 ())
        {
            allUser = dc.database1.ToList();
        }

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

 public JsonResult GetUserWithSerialNumber(string prefix){
    List<database1> allUser = new List<database1>();

    using (dbContext1  dc = new dbContext1())
        {
            allUser = dc.database1.Where(a => a.SerialNumber.Equals(prefix)).ToList();
        }

        return new JsonResult { Data = allUser, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }
所以我把“Int32.MaxValue”放在GetAllUser方法中,现在当我运行这个网页并点击它给我的GetAllUser按钮时

A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.Script: http://localhost:54936/Scripts/jquery-1.10.2.js:7017

除了GetAllUser()之外,我的所有其他方法都可以工作。我的cshtml和其他代码与教程中的完全相同,因此我不确定我做错了什么。

我发现我收到脚本消息的唯一原因是因为我的数据库太大。浏览所有条目、将其放入列表并将其作为对象所花费的时间太长。

请创建并调试
GetAllUser
方法?为什么定义
MaxJsonLength
目的是什么?
A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.Script: http://localhost:54936/Scripts/jquery-1.10.2.js:7017