Authorize attribute w / Roles not working as expected
[Authorize (Roles = "group1")]
does not allow group1.
also if i execute Roles.IsUserInRole ("group1") its false even though user role is correctly identified in asp.net db membership.
what can i lose?
EDIT: If I do that I can read this role, but not like this: Roles.Provider.GetRolesForUser ("username")
source to share
Do you have a RoleProvider profile installed? Is the connection string for the RoleProvider specified in the appropriate database with the correct credentials? Membership and role providers perform different functions, and a configured membership provider will not automatically provide you with role information.
source to share
if you need to use in aspx u page ... where admin is assigned by my role ...
HttpContext.Current.User.IsInRole("admin")
and in the controller if you want to use ....
[Authorize(Roles = "admin")]
where admin is the role I assigned
and if u still can't get it to work try this post ...
If the problem persists, try posting the web.config file and the page where the problem is with the error
source to share