Domanda

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

È stato utile?

Soluzione

This is the correct way:

[Authorize(Users="userName", Roles="admin")]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top