c# - OutputCache - 指定要缓存的内容

标签 c# .net asp.net-mvc asp.net-mvc-3 outputcache

我使用 OutputCache 属性 [OutputCache(Duration = 3600)] 来缓存返回 View 的 Controller 。但该 View 包含一个帮助程序方法,该方法根据 Web.config 属性显示某些信息。问题是这些信息也被缓存了。有没有办法不缓存辅助方法信息。

最佳答案

不幸的是 ASP.NET MVC 2 及更高版本不支持 donut caching :

Due to differences in the way that ASP.NET MVC 2 processes request, data within the substitution block can be cached when it shouldn’t be. Substitution caching for ASP.NET MVC is not supported and has been removed from our ASP.NET MVC Futures project

这是一个 great article解释如何在 ASP.NET MVC 3 及更高版本中实现此目的。它基于 ASP.NET MVC Extensible Donut Caching Codeplex 上提供了软件包。

关于c# - OutputCache - 指定要缓存的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15113679/

相关文章:

c# - cref 不在对象浏览器中创建链接

c# - 拆分 CSV 并排除元素中的逗号

.net - 如何使用 PRISM 创建 XAML 启动屏幕

asp.net-mvc - mvc4数据注释比较两个日期

jquery - 有没有办法在 jquery jqgrid 中以编程方式设置过滤器?

jquery - 如何使用 Jquery Ajax 进行模型绑定(bind)

c# - 如何通过文件名查找 ProjectItem

c# - 哪种软件设计模式最适合以下场景 (C#)

c# - (WPF/MVVM) Service 和 ViewModel 有什么区别?

c# - .NET winforms 应用程序在不使用 ClickOnce 的情况下更新自身的最佳方式是什么?