2
I’m trying to implement permissioning by Roles within my controller:
[PerfilFiltro(Roles = "Administrador,Caixa")]
public ActionResult Index()
{
return View(db.Adicional.ToList());
}
public class PerfilFiltro : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (filterContext.Result is HttpUnauthorizedResult)
filterContext.HttpContext.Response.Redirect("/Home/Negado");
}
}
I want to do it this way:
*The Administrator OR box profiles can open the Index.
What happens when I put between commas is that the role of the logged in user must be administrator and cashier, but I want administrator or cashier.
This is kind of weird... it was supposed to be working. Test without the Profiler class. Use Authorize.
– Danilo Breda