title: ASP.NET MVC2 model binding problem
body: <p>Why is my controller receiving an empty model in this case?</p>
  
  <p>Using</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;X.Models.ProductModel&gt;" %&gt;
  
      &lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
          &lt;h2&gt;Product&lt;/h2&gt;
  
          &lt;% using (Html.BeginForm() {%&gt;
  
              &lt;%: Html.ValidationSummary(true) %&gt;
  
                  &lt;div class="editor-label"&gt;
                      Product Name
                  &lt;/div&gt;
                  &lt;div class="editor-field"&gt;
                      &lt;%: Html.TextBoxFor(model =&gt; model.Name) %&gt;
                      &lt;%: Html.ValidationMessageFor(model =&gt; model.Name) %&gt;
                  &lt;/div&gt;
  
                  &lt;br /&gt;
  
                  &lt;div class="editor-label"&gt;
                      Short Description
                  &lt;/div&gt;
                  &lt;div class="editor-field"&gt;
                      &lt;%: Html.TextAreaFor(model =&gt; model.ShortDesc) %&gt;
                      &lt;%: Html.ValidationMessageFor(model =&gt; model.ShortDesc) %&gt;
                  &lt;/div&gt;
  
                  &lt;br /&gt;
  
                  &lt;div class="editor-label"&gt;
                      Long Description
                  &lt;/div&gt;
                  &lt;div class="editor-field"&gt;
                      &lt;%: Html.TextAreaFor(model =&gt; model.LongDesc) %&gt;
                      &lt;%: Html.ValidationMessageFor(model =&gt; model.LongDesc) %&gt;
                  &lt;/div&gt;
  
                  &lt;p&gt;
                      &lt;input type="submit" value="Create" /&gt;
                  &lt;/p&gt;
  
          &lt;% } %&gt;
  
      &lt;/asp:Content&gt;
  </code></pre>
  
  <p>and the following controller.</p>
  
  <pre><code>using System.Web.Mvc;
  using X.Lib.Services;
  using X.Models;
  
  namespace X.Admin.Controllers
  {
      public class ProductController : Controller
      {
  
          [HttpGet]
          public ActionResult ProductData()
          {
              return View();
          }
  
          [HttpPost]
          public ActionResult ProductData(ProductModel NewProduct)
          {
              //Validate and save
              if(ModelState.IsValid)
              {
                  //Save And do stuff.
                  var ProductServ = new ProductService();
                  ProductServ.AddProduct(NewProduct);
              }
  
              return View();
          }
  
      }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>public class ProductModel
  {
      public int ID;
  
      [Required(ErrorMessage = "Name is required")]
      public string Name;
  
      public string LongDesc;
      public string ShortDesc;
  }
  </code></pre>