I'm trying to build webpage with Microsoft Passport authentication. That works fine but how to use roles for authenticated users?
I have problems to understand how roles is working with 2.0.
I am able to create new role with Roles.CreateRole("TestRole")
but if I have understand right it using Identity 1.0? at least it creates record to Roles table in database not AspNetRoles.
I think that I need to use RoleManager
and UserManager
?
Any examples how to do that with VB.
For creating role use RoleManager
and for assigning role to user Use UserManager
.
RoleManager = New RoleManager(Of IdentityRole)(New RoleStore(Of IdentityRole)(New MyDbContext()))
Dim roleresult = RoleManager.Create(New IdentityRole(roleName))
UserManager.AddToRole(currentUser.Id, roleName)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.