I have a MasterPage in which I display two things: one is the user name which I display with the following command <%: Context.User.Identity.GetUserName() %>
and one is the user role.
How can i display it?
Thank you.
I have a MasterPage in which I display two things: one is the user name which I display with the following command <%: Context.User.Identity.GetUserName() %>
and one is the user role.
How can i display it?
Thank you.
Try it like this if you have access to UserManager:
Or if you have a access to any Identity based user you should be able to get roles also like this:
Or search any Identity user with specific name and get its roles:
I'm using Identity 2.0
UPDATE:
So if you have access UserManager and RoleManager in master page code, you could write a method, which gets user roles like this:
Then it's up to you how you call this in your view or populate these roles to user while loading page.