title: MVC Model Class Casting
body: <p>I have an asp.net mvc application. I have two model class like this:</p>
  
  <pre><code>public class BaseViewModel
  {
      ...
  }
  
  public class DerivedViewModel : BaseViewModel
  {
      ...
  }
  </code></pre>
  
  <p>I have a view and I want to use this view both of these models.</p>
  
  <pre><code>@model BaseViewModel
  ...
  </code></pre>
  
  <p>Inside view, I am able to use like this:</p>
  
  <pre><code>@if (Model.GetType() == DerivedViewModel)){
  @* Properties of Derived class *@
  }
  </code></pre>
  
  <p>I am using a form inside this view like this:</p>
  
  <pre><code>@using (Html.BeginForm("Home", "Application", FormMethod.Post)) {
  ...
  }
  </code></pre>
  
  <p>But when I post the form to controller method, I can't cast base class to derived class. How can I separate derived and base class in the controller method? How can I post correctly?</p>