我使用 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/