【发布时间】:2014-01-17 17:16:17
【问题描述】:
在MVC 中,OutputCacheAttribute 能够阻止执行它正在装饰的操作(如果存在相关缓存)
如何用自定义属性实现相同的机制?
在其他作品中,我希望能够装饰一个动作,并根据属性内部的逻辑来决定该动作是否应该继续执行。
添加
我已经实现了一种机制,如果对操作的请求带有flushaction=flush_silent 之类的查询字符串,自定义属性(扩展OutputCacheAttribute)会使缓存无效。
我还想做的,不是执行动作:
[JHOutputCache(CacheProfile = "ContentPageController.Index")]
public ActionResult Index(string url)
{
//custom code that should not execute when flushing the cache
}
【问题讨论】:
标签: asp.net-mvc custom-attributes outputcache