ASP.NET MVC ViewEngine ViewLocationCache.GetViewLocation 返回 null
我正在关注 Chris Pietschmann 的 ASP.NET MVC 中的主题解决方案。
我注意到的一件事是,在后续请求中不会从 ViewLocationCache 中检索视图名称。 我正在使用 ASP.NET MVC 2.0 RC
当执行以下代码时:
this.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, virtualPath);
我将鼠标悬停在 this.ViewLocationCache 上,它只返回 {System.Web.Mvc.NullViewLocationCache} - 表明没有添加任何内容?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ViewLocationCache
默认情况下仅在发布模式下工作(在web.config
中设置
)。要在调试模式下启用
ViewLocationCache
:在继承自
WebFormViewEngine
的自定义视图引擎中,在 ViewEngine 的构造函数中设置ViewLocationCache
,如下所示:如果您愿意,您还可以覆盖默认缓存时间跨度值。
ViewLocationCache
only works in release mode by default (setting<compilation debug="false">
inweb.config
).To enable
ViewLocationCache
in debug mode:In a custom view engine that inherits from
WebFormViewEngine
, set theViewLocationCache
in your ViewEngine's constructor like so:You can also override the default cache timespan values if you wish.