How can I get userID and roleID of user that is logged to application? User.Identity
doesn't contain these details?
Thanks,
Ile
Here's how:
string userId = Membership.GetUser().ProviderUserKey.ToString();
string[] roleNames = Roles.GetRolesForUser(username);
Another good one to know is:
bool isAdmin = Roles.IsUserInRole("Admin");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With