I created an ActionFilterAttribute that has an OnActionExecuted method. This means that it starts after the Action method. But under certain conditions, I want OnActionExecuted not to execute.
How can I, from the Action method, prevent the execution of an ActionFilter?
Currently I have done this:
In the Action method:
RouteData.Values.Add("CancelActionFilter", true);
And on ActionFilter.OnActionExecuted ():
if (filterContext.RouteData.Values["CancelActionFilter"] != null) { return; }
But I think there may be a more elegant approach.
source share