title: ASP.NET MS11-100: how can I change the limit on the maximum number of posted form values?
body: <p>Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework.  One of the fixes introduced by <a href="http://support.microsoft.com/kb/2656351">MS11-100</a> temporarily mitigates a potential DoS attack involving hash table collisions.  It appears this fix breaks pages that contain a lot of POST data.  In our case, on pages that have very large checkbox lists.  Why would this be the case?</p>
  
  <p>Some non-official sources seem to indicate that MS11-100 places a limit of 500 on postback items.  I can't find a Microsoft source that confirms this.  I know that View State and other framework features eat up some of this limit.  Is there any configuration setting that controls this new limit?  We could switch away from using checkboxes but it works rather well for our particular situation.  We'd also like to apply the patch because it protects against some other nasty things.</p>
  
  <p><a href="http://www.net-security.org/secworld.php?id=12148">Unofficial source discussing the 500 limit:</a></p>
  
  <blockquote>
    <p>The bulletin fixes the DOS attack vector by providing a limit to the
    number of variables that can be submitted for a single HTTP POST
    request. The default limit is 500 which should be enough for normal
    web applications, but still low enough to neutralize the attack as
    described by the security researchers in Germany.</p>
  </blockquote>
  
  <p>EDIT: Source code with example of limit (which appears to be 1,000, not 500)
  Create a standard MVC app and add the following code to the main index view:</p>
  
  <pre><code>@using (Html.BeginForm()) 
  {
      &lt;fieldset class="fields"&gt;
          &lt;p class="submit"&gt;
              &lt;input type="submit" value="Submit" /&gt;
          &lt;/p&gt;
  
          @for (var i = 0; i &lt; 1000; i++)
          {
              &lt;div&gt; @Html.CheckBox("cb" + i.ToString(), true) &lt;/div&gt;
          } 
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>This code worked before the patch.  It doesn't work after.  The error is:</p>
  
  <blockquote>
    <p>[InvalidOperationException: Operation is not valid due to the current
    state of the object.]<br>
    System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
    +82    System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +111<br>
    System.Web.HttpRequest.FillInFormCollection() +307</p>
  </blockquote>