Created
February 8, 2018 12:56
-
-
Save tusmester/c640e986bcc3a5d9aeb844d73e9a8907 to your computer and use it in GitHub Desktop.
#sn #mvc #view #login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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