6

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?

DaveRandom
  • 87,921
  • 11
  • 154
  • 174
Ben Foster
  • 34,340
  • 40
  • 176
  • 285

1 Answers1

10

ViewLocationCache only works in release mode by default (setting <compilation debug="false"> in web.config).

To enable ViewLocationCache in debug mode:
In a custom view engine that inherits from WebFormViewEngine, set the ViewLocationCache in your ViewEngine's constructor like so:

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

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

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Ben Foster
  • 34,340
  • 40
  • 176
  • 285