开发者

ASP.NET MVC ViewEngine ViewLocationCache.GetViewLocation returns null

开发者 https://www.devze.com 2022-12-18 03:22 出处:网络
I am following Chris Piet开发者_C百科schmann\'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 req

I am following Chris Piet开发者_C百科schmann'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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消