I am using MVC Entity Framework and I need to get a user's role within the _LoginPartial for some role-specific functionality within the nav bar. What is the best way to get that there?
I've tried using Dim myRoles = Roles.GetRolesForUser(), but that comes up with nothing. Which is wrong, because I use role-specific functionality elsewhere and that works fine.
Following the link in Marco's comment, it mentions using ClaimsIdentity, but for me it says ClaimsIdentity is not declared (Rick left a comment there this past August explaining it's not working for him like something changed in the past 2 years).
I had also tried this, which is similar to code in a controller I have elsewhere which does work:
Dim context As IOwinContext = New OwinContext
Dim manager = New AppUserManager(New UserStore(Of AppUser(context.Get(Of MyAppIdentityDbContext)()))
Dim userInfo = manager.FindById(curUserID)
Dim userRole As String = userInfo.Roles(0).RoleId
myRole = db.Roles.Where(Function(x) x.Id = userRole).FirstOrDefault().Name
But at runtime I get an error on the "Dim manager" line that says
An exception of type 'System.ArgumentNullException' occurred in Microsoft.AspNet.Identity.EntityFramework.dll but was not handled in user code Additional information: Value cannot be null.
I have no idea what value it's talking about.