Я расширил базовый класс Controller и отлично работал:
Класс ControllerExtensions:
namespace SCAWEB.Helpers
{
public static class ControllerExtensions
{
#region Json
public static int MaxJsonLength{get;set;}
static ControllerExtensions()
{
MaxJsonLength = 2147483644;
}
public static System.Web.Mvc.JsonResult LargeJson(this System.Web.Mvc.Controller controlador, object data)
{
return new System.Web.Mvc.JsonResult()
{
Data = data,
MaxJsonLength = MaxJsonLength,
};
}
public static System.Web.Mvc.JsonResult LargeJson(this System.Web.Mvc.Controller controlador, object data, System.Web.Mvc.JsonRequestBehavior behavior)
{
return new System.Web.Mvc.JsonResult()
{
Data = data,
JsonRequestBehavior = behavior,
MaxJsonLength = MaxJsonLength
};
}
//TODO: You can add more overloads, the controller class has 6 overloads
#endregion
}
}
Класс MyController:
using SCAWEB.Helpers;
namespace SCAWEB.Controllers
{
public class VentasController : Controller
{
public ActionResult VentasList (){
//Todo: All the action code
//return this.Json(myData);
return this.LargeJson(myData);//Here I use my extensions
}
}
}
Вы можете указать максимальную длину в своем коде:
ControllerExtensions.MaxJsonLength = 1073741824;//1GB