I have a controller which return many datas. then i got "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."
i have add my web.config using this. But the error is still occured.
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483645" recursionLimit="100">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
then I add new class LargeJsonResult like on this website http://brianreiter.org/2011/01/03/custom-jsonresult-class-for-asp-net-mvc-to-avoid-maxjsonlength-exceeded-exception/
it said like this in controller
return new LargeJsonResult() { Data = output, MaxJsonLength = int.MaxValue };
but how can I use that with many return data? below is my controller
public ActionResult LoadInitData()
{
try
{
Database db = new Database("CON001");
_employee = Helper.Common.GetEmployeeData(db);
EmployeeDAC dacEmployee = new EmployeeDAC(db);
Employee dataEmployee = dacEmployee.GetDataByComputerLogin(GetUser());
if (_employee.SBU == "FB")
{
BrandBudgetDAC dacBrandBudget = new BrandBudgetDAC(db);
List<BrandBudget> dataBrandBudget = dacBrandBudget.GetDataBrandFB();
PostBudgetDAC dacPostBudget = new PostBudgetDAC(db);
List<PostBudget> dataPostBudget = dacPostBudget.GetDataPostFB();
AreaDAC dacArea = new AreaDAC(db);
List<Area> dataArea = dacArea.GetData();
return Json(new { Employee = dataEmployee, BrandBudget = dataBrandBudget, PostBudget = dataPostBudget, Area = dataArea }, JsonRequestBehavior.AllowGet);
}
else
{
BrandBudgetDAC dacBrandBudget = new BrandBudgetDAC(db);
List<BrandBudget> dataBrandBudget = dacBrandBudget.GetData(_employee.SBU);
PostBudgetDAC dacPostBudget = new PostBudgetDAC(db);
List<PostBudget> dataPostBudget = dacPostBudget.GetData(_employee.SBU);
AreaDAC dacArea = new AreaDAC(db);
List<Area> dataArea = dacArea.GetData();
return Json(new { Employee = dataEmployee, BrandBudget = dataBrandBudget, PostBudget = dataPostBudget, Area = dataArea }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
return Json(new { Error = ex.Message }, JsonRequestBehavior.AllowGet);
}
}