I have a class inheriting from ActionFilterAttribute and IActionFilter. Now I'm implementing the interface methods and applied the filter to the controller and action too. Nothing happens ...
I ensured it by applying some breakpoints all over the filter. To clarify I'm using System.Web.Mvc.Filters and that's most of it I just want to have a filter that the action goes to before it gets executed.
public class AuthJwtFilter : ActionFilterAttribute, IActionFilter
{
public string Realm { get; set; }
void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext)
{
var request = true;
}
}
And just a break point on var request to see if it gets in.
[AuthJwtFilter]
[HttpGet("/test")]
public IActionResult Test()
{
return Ok("Hello");
}
And that is the Controller Action
Remove the
IActionFilterinterface from the class declaration.ActionFilterAttributealready implements that interface.Override the base method:
That should work.
UPDATE: By the way, if you want your filter to fire before the action executes, you should be overriding
OnActionExecutinginstead.