Is it possible with MVC to allow the whole controller to be accessed by 1 role except one or few methods be accessed by another role?
Where all methods belong to the staff except for Method3 can be access by both clients and staff. Something like below:
[Authorize(Roles = "staff")]
public class StaffController : Controller
{
public StaffController()
{
}
public ActionResult Method1()
{
}
public ActionResult Method2()
{
}
[Authorize(Roles = "staff, customer")]
public ActionResult Method3()
{
}
}
Or another scenario where all belong to the staff except for Method3 where it is exclusively accessible by clients, like below:
[Authorize(Roles = "staff")]
public class StaffController : Controller
{
public StaffController()
{
}
public ActionResult Method1()
{
}
public ActionResult Method2()
{
}
[Authorize(Roles = "customer")]
public ActionResult Method3()
{
}
}
However, the above don't work. In both cases, clients still don't have access to Method3.
Greatly appreciate any help!