title: How to use more than 1 Model on a page by using asp.net mvc 5?
body: <p>I want to use 2 models. The first is on <code>Index.cshtml</code> page, and the second is on <code>_Layout.cshtml</code> page</p>
  
  <p>In the controller which contains the action <code>public ActionResult Index(){...}</code>, I declare some values and return it to View(). Like this:</p>
  
  <pre><code>public ActionResult Index()
  {
     HomePageViewModel model = new HomePageViewModel();
     // do something...
     return View(model);
  }
  </code></pre>
  
  <p>And in <code>MyProjectName.Models</code>, I write some classes to check login account and put it on the page <code>_Layout.cshtml</code>. Like this:</p>
  
  <p>On page <code>_Layout.cshtml</code>:</p>
  
  <pre><code>@using MyProjectName.Models
  @model MyProjectName.Models.LoginModel
  
  @if (Model.LoginAccount != null)
  {
     foreach(Account acc in Model.LoginAccount)
     {
        @Html.ActionLink(@acc.Email, "SomeAction", "SomeController", null, new { id = "loginEmail" })
        @Html.ActionLink("Logout", "SomeAction", "SomeController", null, new { id = "logout" })
     }
  }
  </code></pre>
  
  <p>The code on page <code>_Layout.cshtml</code> doesn't work. It said that: I have returned a model (<code>HomePageViewModel model</code>), but some values which I want to render is referenced from <code>MyProjectName.Models.LoginModel</code></p>
  
  <p>Main requirement is: the first model is used to display the content on page <code>Index.cshtml</code>, and the second model is used to check user login (on page <code>_Layout.cshtml</code>).</p>
  
  <p>Can you tell me how to do that? Thank you!</p>