简体   繁体   中英

asp.net core 2 authorization Logout MVC

I currently authenticate my starting View of my MVC Application by adding the following Code to my Controller and it works great.

    [Authorize(Roles = "Domain Users")]

Im wondering if there is also something that allows you to log out of that authorization again. Havent found anything regarding it so far, anyone worked with it before?

This is what i used in a asp.net core 2.2 project of mine.

@using Microsoft.AspNetCore.Identity
@using Website.DAL.Models.Users

@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager


           <form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })" method="post" id="logoutForm" class="ml-auto">
                <ul class="nav navbar-top-links navbar-right">
                    <li><button type="submit" class="fa fa-sign-out btn btn-w-m btn-link">Logout</button></li>
                </ul>
            </form>

However it is logingout the entire user. As far i know there is now way to unsubsribe a user or something like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM