I have some code in my application that I need to execute on every request, before anything else executes (even before authentication). So far I\'ve been us
You could do this in the Initialize method of a base controller.
Another possibility is to register a global filter:
public class MyGlobalFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// that's gonna be hit
}
}
and in the RegisterGlobalFilters
event of your Global.asax
:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new MyGlobalFilter());
}