I want to adjust the _LoginPartial.cshtml to display:
Logged in as <username>(<rolename>) | Logoff
So I wish to add the first role name associated with the logged in user.
I can't access it via the user object, so how do I access this information?
This is the current code:
@Html.ActionLink("Logged in as " + User.Identity.GetUserName(), "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
You'll want to use the Role
class, but really what you should be doing is collecting this information together in the controller & passing it, probably in the ViewBag
. That way your view is abstracted from where you get the username & roles from.