MVC 5 - Roles - AuthorizeAttribute outdated

放肆的年华 提交于 2019-12-24 21:25:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!