views:

104

answers:

1

Hi,

I am following Chris Pietschmann's solution for theming in ASP.NET MVC.

One thing I have noticed is that the view name is not being retrieved from the ViewLocationCache on subsequent requests. I am using ASP.NET MVC 2.0 RC

When the following code is executed:

this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);

and I hover over this.ViewLocationCache it just returns {System.Web.Mvc.NullViewLocationCache} - suggesting nothing was added?

Thanks,

Ben

+1  A: 

I finally got an answer to this on the asp.net forums.

So for the benefit of others.

ViewLocationCache does not work in debug mode by default, it does however work in release mode (setting compilation debug=false in web.config).

To enable the ViewLocationCache in a custom view engine (that inherits WebFormViewEngine) in debug mode you can set the ViewLocationCache in your viewengine's contructor like so:

    public MyCustomViewEngine()
    {
        ViewLocationCache = new DefaultViewLocationCache();
    }

You can also override the default cache timespan values if you wish.

Ben