Skip to content

Instantly share code, notes, and snippets.

@tusmester
Created February 8, 2018 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tusmester/c640e986bcc3a5d9aeb844d73e9a8907 to your computer and use it in GitHub Desktop.
Save tusmester/c640e986bcc3a5d9aeb844d73e9a8907 to your computer and use it in GitHub Desktop.
#sn #mvc #view #login
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginRouteForm("Default", new
{
ReturnUrl = ViewBag.ReturnUrl,
controller = "Account",
action = "LogOff"
}, FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.MvcActionLink("Hello " + User.Identity.Name + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>
}
}
else
{
<ul class="nav navbar-nav navbar-right">
<li>@Html.MvcActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li><a id="loginLink" href="/Root/Sites/Default_Site">Login</a></li>
</ul>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment