views:

27

answers:

1

Are any events raised when a controller requests a view or partial view? Similar to FindView/FindPartialView on the IViewEngine interface. I need to know what views are requested, but dont want to have to write my own view engine.

Any suggestions?

A: 

You don't have to write your own view engine; inherit from WebFormViewEngine and 99% of the work is done:

public class InterceptorViewEngine : WebFormViewEngine
{    
    public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
    {
        Logger.Log(viewName + " view requested");

        return base.FindView(controllerContext, viewName, masterName, useCache);
    }
}
jfar
Thanks jfar, but I dont want to force a particular view engine on end users.I need to do get the view names without the user having to add my custom view engine
Dve
That would have been nice to know in your question...
jfar