views:

73

answers:

2

[Authorize (Roles="group1")]

will not allow group1.

also, if I do Roles.IsUserInRole("group1"), its false despite the users role correctly identified in asp.net membership db.

what could i be missing?

EDIT: if I do this I can read the role, but not as above: Roles.Provider.GetRolesForUser("username")

+1  A: 

Do you have a RoleProvider configured? Is the connection string for the RoleProvider pointed at the proper database with the correct credentials? Membership and Role Providers perform different functions and having a membership provider configured won't automatically give you role information.

tvanfosson
yes using aspnetsqlroleprovider and connection string is good
zsharp
i have no problem adding the role, just reading
zsharp
+1  A: 

if your using in the aspx page u will need this ..... where admin is my role assigned ...

 HttpContext.Current.User.IsInRole("admin")

and in the controller if u want to use ....

[Authorize(Roles = "admin")]

where admin is the role i have assigned

and if u still aren't able to get it working try this post...

if still the problem persists try posting your web.config and page where u r having problem

lucky