Darin Dimitrov is right, use the Application_BeginRequestand methods Application_EndRequest.
Here's how you do it:
protected void Application_BeginRequest()
{
var routeCollection = RouteTable.Routes;
var routeData = routeCollection.GetRouteData(new HttpContextWrapper(HttpContext.Current));
Debug.WriteLine("Invoking " + routeData.Values["Controller"] + "::" + routeData.Values["Action"]);
}
protected void Application_EndRequest()
{
Debug.WriteLine("EndRequest");
}
These methods will be called whether the version is loaded from the cache or not.
source
share