Is there a \"global\" OnActionExecuting that I can override to have all my MVC actions (regardless of controller) do something when they get called? If so, how?
Create one class that Implements IActionFilter and/or IResultFilter:
public class FilterAllActions : IActionFilter, IResultFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
throw new System.NotImplementedException();
}
public void OnActionExecuted(ActionExecutedContext filterContext)
{
throw new System.NotImplementedException();
}
public void OnResultExecuting(ResultExecutingContext filterContext)
{
throw new System.NotImplementedException();
}
public void OnResultExecuted(ResultExecutedContext filterContext)
{
throw new System.NotImplementedException();
}
}
And register it on Global.asax
protected void Application_Start()
{
//...
RegisterGlobalFilters(GlobalFilters.Filters);
//...
}
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new FilterAllActions());
}