How can I get the user ID and roleID of the user registered in the application? User.Identity does not contain this data?
User.Identity
Thanks,Ile
Here's how:
string userId = Membership.GetUser().ProviderUserKey.ToString(); string[] roleNames = Roles.GetRolesForUser(username);
Another good way to find out:
bool isAdmin = Roles.IsUserInRole("Admin");
You can also use this:
List<String> roles = Roles.GetRolesForUser().ToList();
Source: https://habr.com/ru/post/1308747/More articles:NHibernate set: should I override Equals and GetHashCode? - equalsWhen binding a client TCP socket to a specific local port with Winsock, SO_REUSEADDR has no effect - cSchedule and execute PHP script automatically - windowsVisual Studio 2010 freezes when launching asp.net site debugging - asp.netSQL query: SUM values ββbefore the current record - sqlLinux: how to send a TCP packet from a specific port? - linuxVisual Studio (2010): is there a hotkey for switching all open tool windows? - macrosHow can I get a WorkbookPart from a WorkSheet? - excelPotential Field Method: Real Robots - roboticsAutocomplete suggestions in the source editor - javaAll Articles