Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Login and Logout Links
@if (User.Identity.IsAuthenticated)
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity"
asp-controller="Account" asp-action="SignOut">
Sign out
</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity"
asp-controller="Account" asp-action="SignIn">
Sign in
</a>
</li>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment