I'have project in Visual Studio in Framework 4.5.
It is a ASP.NET MVC 4 WebApllication. I'm using JSON to get a lot of data. But when i execute it, it gives me that error: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
So, i want to modify max json length with this code:
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
{
return new JsonResult()
{
Data = data,
ContentType = contentType,
ContentEncoding = contentEncoding,
JsonRequestBehavior = behavior,
MaxJsonLength = Int32.MaxValue
};
}
But i can't, because I get an error in line **MaxJsonLength = Int32.MaxValue **
Error is: System.Web.Mvc.JsonResult' does not contain a definition for 'MaxJsonLength
I have these references in class of controller:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using WebserviceIPAD.Areas.Api.Models;
- using System.Web.Script.Serialization;
But still getting an error: System.Web.Mvc.JsonResult' does not contain a definition for 'MaxJsonLength
Any one knows if I have to import more references?
Thanks.