在IdentityUserRole 2.0 ASP.NET中获取角色名称 [英] Get Role name in IdentityUserRole 2.0 in ASP.NET
本文介绍了在IdentityUserRole 2.0 ASP.NET中获取角色名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DLL的实体框架的更新之前,我是能够做到这一点。
Before the update of the dll's in the Entity Framework i was able to do this
user.Roles.Where(r => r.Role.Name == "Admin").FisrtOrDefault();
现在,我只能做r.RoleId,我不能找到一种方法中检索塔尔角色ID的名称。我在我的控制器,在我AuthorizeAttribute类用这个。
Now, i can only do r.RoleId, and i can't find a way to retreive the name of thar Role Id. I'm using this in my controllers and in my AuthorizeAttribute class.
有人可以帮助我在这里?
Can someone help me here?
问候
推荐答案
询问的 RoleMananger ?
RoleManager.Roles.
// or
RoleManager.FindByIdAsync()
// or
RoleManager.FindByNameAsync()
您可能要花费一些时间和学习 Asp.Net安全一>和 Asp.Net身份。
You may want to take some time and learn the new security features in Asp.Net Security and Asp.Net Identity.
这篇关于在IdentityUserRole 2.0 ASP.NET中获取角色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文