Pulse7
7/27/2017 - 7:47 PM

Another Identity logout login example

Another Identity logout login example

[HttpPost]
        public async Task<IActionResult> Logout()
        {
            await _signInManager.SignOutAsync();
            return RedirectToAction("Index", "Home");
        }
@if (User.Identity.IsAuthenticated)
        {
            <div>@User.Identity.Name</div>
            <form method="post" asp-controller="Account" asp-action="Logout">
                <input type="submit" value="Logout"/>
            </form>
        }
        else
        {
            <a asp-controller="Account" asp-action="Login">Login</a>
            <a asp-controller="Account" asp-action="Register">Register</a>
        }