title: ASP.NET MVC UpdateModel with interface
body: <p>I am trying to get UpdateModel to populate a model that is set as only an interface at compile-time. For example, I have:</p>
  
  <pre><code>// View Model
  public class AccountViewModel {
    public string Email { get; set; }
    public IProfile Profile { get; set; }
  }
  
  // Interface
  public interface IProfile {
    // Empty
  }
  
  // Actual profile instance used
  public class StandardProfile : IProfile {
    public string FavoriteFood { get; set; }
    public string FavoriteMusic { get; set; }
  }
  
  // Controller action
  public ActionResult AddAccount(AccountViewModel viewModel) {
    // viewModel is populated already
    UpdateModel(viewModel.Profile, "Profile"); // This isn't working.
  }
  
  // Form
  &lt;form ... &gt;
    &lt;input name='Email' /&gt;
    &lt;input name='Profile.FavoriteFood' /&gt;
    &lt;input name='Profile.FavoriteMusic' /&gt;
    &lt;button type='submit'&gt;&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Also note that I have a custom model binder that inherits from DefaultModelBinder being used that populates IProfile with an instance of StandardProfile in the overriden CreateModel method.</p>
  
  <p>The problem is that FavoriteFood and FavoriteMusic are never populated. Any ideas? Ideally this would all be done in the model binder, but I'm not sure it is possible without writing a completely custom implementation.</p>
  
  <p>Thanks, Brian</p>