Skip to content

Instantly share code, notes, and snippets.

@danieleli
Last active January 17, 2016 16:39
Show Gist options
  • Save danieleli/e463d57fbd34fc705684 to your computer and use it in GitHub Desktop.
Save danieleli/e463d57fbd34fc705684 to your computer and use it in GitHub Desktop.
@using Microsoft.AspNet.Identity
<!-- do we have a user -->
@if (Request.IsAuthenticated)
{
<!-- we have user, so display user name. -->
<div class="username">
@User.Identity.GetUserName()
</div>
}
else
{
<!-- no user so display register and login -->
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment