title: ASP.NET MVC model binding an IList<> parameter
body: <p><strong>[I solved this myself, see my answer for cause]</strong></p>
  
  <p>I'm having trouble getting form values for a IList&lt;> argument in a controller method set properly.</p>
  
  <p>My controller class looks like this:</p>
  
  <pre><code>public class ShoppingBasketController : Controller {
  
      public ActionResult Index() {
          return View();
      }
  
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Add(IList&lt;ShoppingBasketItem&gt; items) {
          Session["basket"] = items; // for testing
          return RedirectToAction("Index");
      }
  }
  public class ShoppingBasketItem {
       public int ItemID;
       public int ItemQuantity;
  }
  </code></pre>
  
  <p>The slightly trimmed form:</p>
  
  <pre><code>&lt;% using (Html.BeginForm("Add", "ShoppingBasket")) { %&gt;
      &lt;% int codeIndex = 0;
      foreach (Product product in products) { %&gt;
          &lt;%= Html.Hidden("items[" + codeIndex + "].ItemID", product.Id) %&gt;
          &lt;%= Html.TextBox("items[" + codeIndex + "].ItemQuantity", "0", new { size = "2"}) %&gt;
          &lt;% codeIndex++;
      }
  } %&gt;
  </code></pre>
  
  <p>Which produces markup like:</p>
  
  <pre><code>&lt;form action="/Basket/Add" method="post"&gt;
      &lt;input id="items[0]_ItemID" name="items[0].ItemID" type="hidden" value="1" /&gt;
      &lt;input id="items[0]_ItemQuantity" name="items[0].ItemQuantity" size="2" type="text" value="0" /&gt;
  
      &lt;input id="items[1]_ItemID" name="items[1].ItemID" type="hidden" value="2" /&gt;
      &lt;input id="items[1]_ItemQuantity" name="items[2].ItemQuantity" size="2" type="text" value="0" /&gt;
  
      &lt;input id="items[2]_ItemID" name="items[2].ItemID" type="hidden" value="3" /&gt;
      &lt;input id="items[2]_ItemQuantity" name="items[2].ItemQuantity" size="2" type="text" value="0" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've checked the form values that get submitted and they are correct. The correct number of <code>ShoppingBasketItem</code>s also get put into <code>Session["basket"</code>], however both the <code>ItemID</code> and <code>ItemQuantity</code> of each are zero. It appears to be correctly decoding the list of form values, but not picking up the properties themselves.</p>
  
  <p>I'm using MVC RC2, and based on an <a href="http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx" rel="noreferrer">article by Scott Hanselman</a> I'm pretty sure my code is correct. Am I missing something?</p>