Did you subclass VirtualPathProviderViewEngine or WebFormViewEngine? If so, the view lookup cache is by default disabled in debug mode. Remove the
debug="true" part from Web.config to compile your site in release mode and disable debugging:
<compilation debug="true">
If you need to unit test your view engine, you can set the view location cache as appropriate from within your unit test.
retroviz
Participant
898 Points
249 Posts
ViewLocationCache always empty
Jan 26, 2010 08:28 PM|LINK
I have written a custom ViewEngine and am calling the following within the FindView method:
this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);
However, subsequent requests never hit the cache as it always returns null.
I am using ASP.NET MVC 2.0 RTM.
When I step through my code even after just calling the above code, hovering over ViewLocationCache appears to be null.
Thanks,
Ben
ViewLocationCache
levib
Star
7702 Points
1099 Posts
Microsoft
Re: ViewLocationCache always empty
Jan 26, 2010 10:40 PM|LINK
Did you subclass VirtualPathProviderViewEngine or WebFormViewEngine? If so, the view lookup cache is by default disabled in debug mode. Remove the debug="true" part from Web.config to compile your site in release mode and disable debugging:
If you need to unit test your view engine, you can set the view location cache as appropriate from within your unit test.
retroviz
Participant
898 Points
249 Posts
Re: ViewLocationCache always empty
Jan 27, 2010 08:42 AM|LINK
Hi,
Thanks for your response. I am inheriting WebFormViewEngine
Is there way of enabling the cache in debug mode?
Thanks,
Ben
levib
Star
7702 Points
1099 Posts
Microsoft
Re: ViewLocationCache always empty
Jan 27, 2010 08:49 AM|LINK
Set your derived type's ViewLocationCache property to be an instance of DefaultViewLocationCache. You can do this from the constructor.
retroviz
Participant
898 Points
249 Posts
Re: ViewLocationCache always empty
Jan 27, 2010 11:34 AM|LINK
That worked. Thankyou.
When in release mode, with the ViewLocationCache enabled, just this use the timespan settings as per the DefaultViewLocationCache (15mins)?
Thanks,
Ben