2017-02-10 10 views
0

私はthisチュートリアルを行っています。私は今のように私JsonResultメソッドが動作していない/読み込み中

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

を持って私のコントローラクラスで

GetUserWithSerialNumberは()それがに仮定されるものを返しますが、GetAllUser()が動作しません。もともとGetAllUser()が働いていた、それは私がGetAllUser方法で「Int32.MaxValueを」を入れて、私はWebページを実行し、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 
を与えてくれ

"The length of the string exceeds the value set on the maxJsonLength property." 

を与えました

私の他のすべてのメソッドは、GetAllUser()を除いて機能します。私のcshtmlと他のコードは、チュートリアルの上にあるように見えるので、私は何が間違っているのか分かりません。

+0

[最小完全検証](http://stackoverflow.com/help/mcve)を作成し、 'GetAllUser'メソッドもデバッグしてください。なぜあなたは 'MaxJsonLength'を定義していますか?目的は何ですか? –

答えて

0

私はデータベースが巨大であるため、私はスクリプトメッセージを受け取る唯一の理由を発見しました。すべてのエントリを調べてリストに入れ、オブジェクトとして配置するには時間がかかりすぎます。

関連する問題