I'm using MVC 4.
I code this customer attribute that inherits from System.Web.Mvc.ActionFilterAttribute
public class AuthorizedAttribute : ActionFilterAttribute
{
public AccessLevel Threshold { get; set; }
public AuthorizedAttribute()
{
Threshold = AccessLevel.Anonymous;
}
public AuthorizedAttribute(AccessLevel threshold)
{
Threshold = threshold;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//some actions
base.OnActionExecuting(filterContext);
}
}
And I'm using it on action Manage
in my UserController
public class UserController : Controller
{
[HttpGet]
[Authorized(AccessLevel.Administrator)]
public ViewResult Manage()
{
return View();
}
}
I put a breakpoint in my attribute contructor, in the overrided method OnActionExecuting
and in my UserController
and when I call the action url through my browser in debug mode only my controller breakpoint is firing and I land on the page even I'm not authenticated..
What am I doing wrong ?
Thank in advance.