You can use this:
void IHttpModule.Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new System.EventHandler(context_PreRequestHandlerExecute);
}
And then you can check if it is the MVC handler (type MvcHandler
) which will execute your request:
void context_PreRequestHandlerExecute(object sender, System.EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
Type mvcht = typeof(System.Web.Mvc.MvcHandler);
if (context.Handler != null && context.Handler.GetType().IsAssignableFrom(mvcht))
{
..... Code goes here.
}
}