In my ASP.NET MVC 4 controller class I have actions that I decorate with CustomAuthorize
attribute so the access is restricted to some roles.
I would like to get the roles from inside the action methods and for this I need the CustomAuthorize attribute that the method is decorated with.
How do I do this?
Sample code of what I am trying to do is below:
public class TestController : Controller
{
// Only the users in viewer and admin roles should do this
[CustomAuthorize("viewer", "admin")]
public ActionResult Index()
{
//Need CustomAuthorizeAttribute so I get the associated roles
}
}
CustomAuthorizeAttribute
is a subclass of System.Web.Mvc.AuthorizeAttribute.