MaxJsonLength exception

MaxJsonLength exception in ASP.NET MVC4 during JavascriptSerializer:

Code:
public ActionResult Index(){
    var data = null  //give some large data e.g big list of values
    var resultData = Json(data, JsonRequestBehavior.AllowGet);
    resultData.MaxJsonLength = Int32.MaxValue;
    return resultData;
}

Note: Then web.config setting is ignored by the default JsonResult implementation. So we might need to implement a custom Json Result or we can use the above code.

Comments

Popular posts from this blog

Get unique/distinct values from an array using JQuery $.grep and $.inArray

Enable Windows 8 App(HTML) to make XHR request to service hosted in different domain

Creating custom controls for Windows Store App (Javascript- WinJS)