title: Multiple models in a view
body: <p>I want to have 2 models in one view. The page contains both <code>LoginViewModel</code> and <code>RegisterViewModel</code>.</p>
  
  <p><strong>e.g.</strong></p>
  
  <pre><code>public class LoginViewModel
  {
      public string Email { get; set; }
      public string Password { get; set; }
  }
  
  public class RegisterViewModel
  {
      public string Name { get; set; }
      public string Email { get; set; }
      public string Password { get; set; }
  }
  </code></pre>
  
  <p>Do I need to make another ViewModel which holds these 2 ViewModels?</p>
  
  <pre><code>public BigViewModel
  {
      public LoginViewModel LoginViewModel{get; set;}
      public RegisterViewModel RegisterViewModel {get; set;}
  }
  </code></pre>
  
  <p>I need the validation attributes to be brought forward to the view. This is why I need the ViewModels.</p>
  
  <p>Isn't there another way such as (without the <code>BigViewModel</code>):</p>
  
  <pre><code> @model ViewModel.RegisterViewModel
   @using (Html.BeginForm("Login", "Auth", FormMethod.Post))
   {
          @Html.TextBoxFor(model =&gt; model.Name)
          @Html.TextBoxFor(model =&gt; model.Email)
          @Html.PasswordFor(model =&gt; model.Password)
   }
  
   @model ViewModel.LoginViewModel
   @using (Html.BeginForm("Login", "Auth", FormMethod.Post))
   {
          @Html.TextBoxFor(model =&gt; model.Email)
          @Html.PasswordFor(model =&gt; model.Password)
   }
  </code></pre>