views:

630

answers:

2

How can I get userID and roleID of user that is logged to application? User.Identity doesn't contain these details?

Thanks,
Ile

+2  A: 

Here's how:

string userId = Membership.GetUser().ProviderUserKey.ToString();
string[] roleNames = Roles.GetRolesForUser(username);
Anders Nygaard
+1  A: 

Another good one to know is:

bool isAdmin =  Roles.IsUserInRole("Admin");
Morph

related questions