ASP.NET MVC ViewEngine ViewLocationCache.GetViewLocation returns null

I am following the Chris Pietschmann solution for hosting in ASP.NET MVC .

One thing I noticed is that the view name is not retrieved from 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'm on that .ViewLocationCache it just returns {System.Web.Mvc.NullViewLocationCache} - suggesting nothing was added?

+6
asp.net-mvc
source share
1 answer

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

To enable ViewLocationCache in debug mode:
In a custom view engine that inherits from WebFormViewEngine , set ViewLocationCache in your ViewEngine constructor as follows:

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

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

+10
source share

All Articles