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

有帮助吗?

解决方案

This is the correct way:

[Authorize(Users="userName", Roles="admin")]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top