title: Is it possible to use @model in _LoginPartial.cshtml?
body: <p>I need to get some data from my DB from <code>_LoginPartial.cshtml</code>. Is it possible to use <code>@model</code> in <code>_LoginPartial.cshtml</code>? Or how is it done? Just by <code>@using WebApp.Services</code> and then directly retrieve the data from the service? Or it there a more elegant way doing this? </p>
  
  <p>I tried to do it with <code>@model</code> but didn't work because the <code>@model</code> in <code>_LoginPartial.cshtml</code> got overridden by another <code>@model</code>. <code>_LoginPartial.cshtml</code> is "injected" into every page/view.</p>
  
  <p><code>Views/Shared/_LoginPartial.cshtml</code></p>
  
  <pre><code>@model WebApp.ViewModels.LoginPartialViewModel
  @Html.ActionLink("" + User.Identity.Name + " (" + Model.Email + ")", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
  </code></pre>
  
  <p><code>ViewModels/ManageViewModels.cs</code></p>
  
  <pre><code>public class LoginPartialViewModel
  {
      public string Email = new UserService().ReadCurrent().Email;
  }
  </code></pre>
  
  <p>And the <code>Views/Shared/_LoginPartial.cshtml</code> is used in <code>Views/Shared/_Layout.cshtml</code> like this:</p>
  
  <pre><code>@Html.Partial("_LoginPartial")
  </code></pre>
  
  <p>Could this be done with <code>@model</code> or would i have to do some nasty thing in <code>Views/Shared/_LoginPartial.cshtml</code> like this:</p>
  
  <pre><code>@using WebApp.Services
  var userService = new UserService();
  var email = userService.Read(User.Identity.GetUserId()).Email;
  @Html.ActionLink("" + User.Identity.Name + " (" + email + ")", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
  </code></pre>