ASP.NET MVC ViewEngine ViewLocationCache.GetViewLocation返回null

Ben*_*ter 6 asp.net asp.net-mvc viewengine

我正在关注Chris Pietschmann 在ASP.NET MVC中使用主题解决方案.

我注意到的一件事是在后续请求中没有从ViewLocationCache中检索视图名称.我正在使用ASP.NET MVC 2.0 RC

执行以下代码时:

this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);
Run Code Online (Sandbox Code Playgroud)

我将鼠标悬停在this.ViewLocationCache上它只返回{System.Web.Mvc.NullViewLocationCache} - 建议什么都没有添加?

Ben*_*ter 10

ViewLocationCache只有在释放模式在默认情况下(设置工作<compilation debug="false">web.config).

要启用ViewLocationCache调试模式:
在从继承的自定义视图引擎WebFormViewEngine,将ViewLocationCache您的视图引擎的构造函数如下所示:

public MyCustomViewEngine()
{
    ViewLocationCache = new DefaultViewLocationCache();
}
Run Code Online (Sandbox Code Playgroud)

如果愿意,您还可以覆盖默认的缓存时间跨度值.