简体   繁体   中英

Connect [Authorize] with custom database

How do I order the [Authorize] attribute to connect to my own Roles database to check for specifics roles in there?

What I know :

  • I have to create a class that inherits from AuthorizeAttribute .

What I don't know :

  • What to write inside my custom class in the way that [CustomAuthorize(Roles: "Administrator")] checks if the current user has that role.

Please, I really need help with this.

重写AuthorizeCore()方法并返回true或false。

只需创建一个自定义RoleProvider即可使用ASP.NET标识。

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