I am sending a POST request to an MVC controller with a large amount of JSON data in the body and it is throwing the following:
ArgumentException: Error during serialization or deserialization using
the JSON JavaScriptSerializer. The length of the string exceeds
the value set on the maxJsonLength property.
Parameter name: input
To remedy this, I have tried a number of Web.Config solutions. Namely:
<system.web>
...
<httpRuntime maxRequestLength="2147483647" />
</system.web>
...
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>
Now, the controller that I am communicating with is in its own Area, with its own Web.Config. I have tried placing the above in either the root or the Area's Web.Config individually, but neither are working. When I debug on a different method within the same controller, I get the default JSON Max Length with the following:
Console.WriteLine(new ScriptingJsonSerializationSection().MaxJsonLength);
// 102400
Here is the method that I am wanting to POST against:
[HttpPost]
public JsonResult MyMethod (string data = "") { //... }
How can I increase the Max JSON Length for the MVC Controller so that my request can successfully reach the method?
Edit: Added <httpRuntime maxRequestLength="2147483647" />
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…