title: MVC Custom ViewModel and auto binding
body: <p>I have a custom ViewModel defined as :</p>
  
  <pre><code>public class SampleFormViewModel
  {
      public SampleFormViewModel(SelectList companies, Widget widget)
      {
          Companies = companies;
          Widget = widget;
      }
  
      public SelectList Companies { get; private set; }
      public Widget Widget { get; private set; }
  }
  </code></pre>
  
  <p>In my Edit POST handler I have the following entry:</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post)]
  public ActionResult Edit(SampleFormViewModel model)
  {
  </code></pre>
  
  <p>Edit form is set up as:</p>
  
  <pre><code>Inherits="System.Web.Mvc.ViewPage&lt;Sample.Web.Models.SampleFormViewModel&gt;"
  </code></pre>
  
  <p>And it just blows up, not sure what’s going on, has the following error:
  No parameterless constructor defined for this object.
  Certain I’m missing something really obvious here. Some background, the GET works perfectly and display the dropdown from the SelectList as expected.
  I’m guessing the auto-binding back to the custom view model is what is failing but not sure what to do about it.</p>