MVC3 Authorize Attribute
-
29-06-2021 - |
Question
How to add Roles and Users to the same action on a controller.
I tried:
[Authorize(Roles = "admin" , Users = "userName")]
public ActionResult Action()
{
....
....
}
[Authorize(Roles = "admin")]
[Authorize(Users = "userName")]
public ActionResult Action()
{
....
....
}
Do i have to create a custom Authorize Attribute?
Thanks
Solution
This is the correct way:
[Authorize(Users="userName", Roles="admin")]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow