title: JsonMaxLength exception on deserializing large json objects
body: <p><strong>Intro:</strong></p>
  
  <p>Web application, ASP.NET MVC 3, a controller action that accepts an instance of POCO model class with (potentially) large field.</p>
  
  <p>Model class:</p>
  
  <pre><code>public class View
  {
      [Required]
      [RegularExpression(...)]
      public object name { get; set; }
      public object details { get; set; }
      public object content { get; set; } // the problem field
  }
  </code></pre>
  
  <p>Controller action:</p>
  
  <pre><code>[ActionName(...)]
  [Authorize(...)]
  [HttpPost]
  public ActionResult CreateView(View view)
  {
      if (!ModelState.IsValid) { return /*some ActionResult here*/;}
      ... //do other stuff, create object in db etc. return valid result
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>An action should be able to accept large JSON objects (at least up to hundred megabytes in a single request and that's no joke). By default I met with several restrictions like <code>httpRuntime maxRequestLength</code> etc. - all solved except MaxJsonLengh - meaning that default ValueProviderFactory for JSON is not capable of handling such objects.</p>
  
  <p><strong>Tried:</strong></p>
  
  <p>Setting </p>
  
  <pre class="lang-xml prettyprint-override"><code>  &lt;system.web.extensions&gt;
      &lt;scripting&gt;
        &lt;webServices&gt;
          &lt;jsonSerialization maxJsonLength="2147483647"/&gt;
        &lt;/webServices&gt;
      &lt;/scripting&gt;
    &lt;/system.web.extensions&gt;
  </code></pre>
  
  <ul>
  <li>does not help.</li>
  </ul>
  
  <p>Creating my own custom ValueProviderFactory as described in @Darin's answer here:</p>
  
  <p><a href="https://stackoverflow.com/questions/9509721/jsonvalueproviderfactory-throws-request-too-large">JsonValueProviderFactory throws &quot;request too large&quot;</a></p>
  
  <ul>
  <li>also failed because I have no possibility to use JSON.Net (due to non-technical reasons). I tried to implement correct deserialization here myself but apparently it's a bit above my knowledge (yet). I was able to deserialize my JSON string to <code>Dictionary&lt;String,Object&gt;</code> here, but that's not what I want - I want to deserialize it to my lovely POCO objects and use them as input parameters for actions.</li>
  </ul>
  
  <p><strong>So, the questions:</strong></p>
  
  <ol>
  <li>Anyone knows better way to overcome the problem without implementing universal custom ValueProviderFactory?</li>
  <li>Is there a possibility to specify for what specific controller and action I want to use my custom ValueProviderFactory? If I know the action beforehand than I will be able to deserialize JSON to POCO without much coding in ValueProviderFactory...</li>
  <li>I'm also thinking about implementing a custom ActionFilter for that specific problem, but I think it's a bit ugly.</li>
  </ol>
  
  <p>Anyone can suggest a good solution?</p>