MVC 5 - Roles - AuthorizeAttribute Deprecated

In a previous post, I asked how to check / add user roles, but now I am facing a different problem. Since microsoft switched to the new Identity 2.0, AuthorizeAttribute no longer works.

Is there any alternative filter for Authorize?

EDIT:

I did some tests and [Authorize (Users = "SOME_ID")] works, but not [Authorize (Roles = "Admin")].

And I checked if the user really was in this role (Admin)

0
source share
1 answer

In fact, [Authorize (Roles = "ROLENAME")] works fine.

Check the userRoles table (or AspNetUserRoles) for the assigned roles for the identifier you are using, which is SOME_ID according to your question. If not, you need to properly assign "Admin" roles to users when creating users.

hope this helps.

+1
source

Source: https://habr.com/ru/post/1202143/


All Articles