2

I have a simple method which returns large chunk of data:

public async Task<JsonResult> GetLargeDataTest()
{
    var list = await _service.GetLargeDataTest();
    return Json(new { response = list });
}

The code above works fine on my local machine. I also tried on one of my local servers, again, everything is working. However I can't make it work on one of the production servers. Tt throws an error:

"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."

I'm struggling with that server configuration. (I even enable all IIS features)

I tried setting the "system.web.extensions" section group and "jsonSerialization maxJsonLength="2147483647"" in web.config, but still getting the same error.

The only one thing that sort of "helped", when i set MaxJsonLength = Int32.MaxValue directly in my code, but in this case response takes about 40-50 seconds, which is odd, since I the same response takes 2 seconds on my local setup and on another server. I don't think the issue is with the code, as it works fine, but I've run out of any other options that could address this error.

Has anyone experienced anything like this? Any idea where to look?

Sorantis
  • 14,496
  • 5
  • 31
  • 37
progproger
  • 958
  • 2
  • 10
  • 21
  • is it downloading exactly the same data on all the machines, from exactly the same remote location? How big is the data, exactly? – ADyson Nov 01 '18 at 14:08
  • @ADyson Yes. The same data ofc. Data is about 120k characters. (Thanks for response) – progproger Nov 01 '18 at 14:11
  • did you try https://stackoverflow.com/questions/10966328/getting-the-json-request-was-too-large-to-be-deserialized/10969382#10969382 ? – Yas Ikeda Nov 01 '18 at 14:14
  • Yes. Sorry, forgot to mention that i also tried to add aspnet:MaxJsonDeserializerMembers key – progproger Nov 01 '18 at 14:15

0 Answers0