_LoginPartial.cshtml 986 B

1234567891011121314151617181920212223
  1. @using Microsoft.AspNet.Identity
  2. @if (Request.IsAuthenticated)
  3. {
  4. using (Html.BeginForm("LogOff", "Account", new { area = "" }, FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
  5. {
  6. @Html.AntiForgeryToken()
  7. <ul class="nav navbar-nav navbar-right">
  8. <li>
  9. @Html.ActionLink("你好," + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: new { area = "" }, htmlAttributes: new { title = "Manage" })
  10. </li>
  11. <li><a href="javascript:sessionStorage.removeItem('accessToken');$('#logoutForm').submit();">注销</a></li>
  12. </ul>
  13. }
  14. }
  15. else
  16. {
  17. <ul class="nav navbar-nav navbar-right">
  18. <li>@Html.ActionLink("注册", "Register", "Account", routeValues: new { area = "" }, htmlAttributes: new { id = "registerLink" })</li>
  19. <li>@Html.ActionLink("登录", "Login", "Account", routeValues: new { area = "" }, htmlAttributes: new { id = "loginLink" })</li>
  20. </ul>
  21. }