MVC 5 Increase Max JSON Length in POST Request
<p>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:</p>
<blockquote>
<p>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</p>
</blockquote>
<p>To remedy this, I have tried a number of <code>Web.Config</code> solutions. Namely:</p>
<pre><code>&lt;system.web&gt; 
...
&lt;httpRuntime maxRequestLength=&quot;2147483647&quot; /&gt;
&lt;/system.web&gt;

...

&lt;system.web.extensions&gt;
  &lt;scripting&gt;
    &lt;webServices&gt;
      &lt;jsonSerialization maxJsonLength=&quot;2147483644&quot;/&gt;
    &lt;/webServices&gt;
  &lt;/scripting&gt;
&lt;/system.web.extensions&gt;
</code></pre>
<p>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:</p>
<pre><code>Console.WriteLine(new ScriptingJsonSerializationSection().MaxJsonLength);
// 102400
</code></pre>
<p>Here is the method that I am wanting to POST against:</p>
<pre><code>[HttpPost]
public JsonResult MyMethod (string data = &quot;&quot;) { //... }
</code></pre>
<p>How can I increase the Max JSON Length for the MVC Controller so that my request can successfully reach the method?</p>
<p>Edit: Added <code>&lt;httpRuntime maxRequestLength=&quot;2147483647&quot; /&gt;</code></p>