get current user's role

前端 未结 7 1928
逝去的感伤
逝去的感伤 2020-12-29 20:11

Is there any way to get the explicit role that a user belongs to in my controller? This assumes using ASP.NET Membership and Role Providers. \"IsInRole\" doesn\'t work - I n

7条回答
  •  没有蜡笔的小新
    2020-12-29 20:30

    You can get a list of Roles from the GetRoles method. (From the link)

      string[] rolesArray;
    
      public void Page_Load()
      {
           RolePrincipal r = (RolePrincipal)User;
           rolesArray = r.GetRoles();
           ...//extra code
      }
    

提交回复
热议问题