2

I was facing the max json length problem so as suggested by various sources on the internet, i increased the default json length in the configuration file like

<system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="900000000"></jsonSerialization>
      </webServices>
    </scripting>
  </system.web.extensions>

but the problem persisted. Then i came across a fantastic blog post that suggested to write my own ActionResult. i am using the telerik grid for mvc along with mvc3.net. Any idea why the serializer ignoring the config.

John x
  • 4,031
  • 8
  • 42
  • 67
  • possible duplicate of [MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer](http://stackoverflow.com/questions/5692836/maxjsonlength-exception-in-asp-net-mvc-during-javascriptserializer) – jrummell Mar 06 '12 at 13:53

2 Answers2

1

MaxJsonLength and ASP.NET MVC

In ASP.NET MVC, it seems you need to set the MaxJsonLength during the execution:

public JsonResult GetData()
{
    var model = GetModel();

    var outputJsonResult = Json(model);
    outputJsonResult.MaxJsonLength = 10 * 1024 * 1024; // 10 MB

    return outputJsonResult;
}
Matthieu Charbonnier
  • 2,794
  • 25
  • 33
1

Having struggled with this myself, unfortunately, for now, this is the only solution.

Also see this question and answer for more details: MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

Community
  • 1
  • 1
lomaxx
  • 113,627
  • 57
  • 144
  • 179