Roles available with Windows Authentication

后端 未结 4 1834
旧时难觅i
旧时难觅i 2021-01-31 22:30

I\'m trying to add Roles authentication to an Action in a Controller in an ASP.NET MVC application. The code looks something like this:

[Authorize(Roles = \"Some         


        
4条回答
  •  梦毁少年i
    2021-01-31 22:49

    Add this to your web.config under system.web:

    
    

    Then you can use:

    string[] arr = Roles.GetRolesForUser(User.Identity.Name);
    

    or:

    string[] arr = Roles.GetRolesForUser();
    

提交回复
热议问题