简体   繁体   English

asp.net core 2授权注销MVC

[英]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. 我目前正在通过将以下代码添加到Controller来验证我的MVC应用程序的初始视图,并且效果很好。

    [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? 到目前为止,Havent发现了有关它的任何东西,以前有人使用过吗?

This is what i used in a asp.net core 2.2 project of mine. 这就是我在我的asp.net core 2.2项目中使用的内容。

@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. 据我所知,现在有一种取消订阅用户之类的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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