问题
In my previous post i asked how to check/add user roles, but now i face another problem. Since microsoft moved to the new Identity 2.0, AuthorizeAttribute doesn't work anymore.
Is there any substitute filter for the Authorize?
EDIT:
I've made some tests and [Authorize(Users = "SOME_ID")] works, but not [Authorize(Roles = "Admin")].
And i verified if the user was really in that role (Admin)
回答1:
Actually [Authorize(Roles = "ROLENAME")] working fine.
Check your userRoles (or AspNetUserRoles) table for assigned roles for the id your have used that is SOME_ID according to your question. If not you have to correctly assign role "Admin" to the users when you create users.
hope this helps.
来源:https://stackoverflow.com/questions/25743113/mvc-5-roles-authorizeattribute-outdated