ASP.NET MVC ViewEngine ViewLocationCache.GetViewLocation 返回 null

发布于 2024-08-18 19:19:39 字数 533 浏览 12 评论 0原文

我正在关注 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沦落红尘 2024-08-25 19:19:39

ViewLocationCache 默认情况下仅在发布模式下工作(在 web.config 中设置 )。

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文