可以为一个操作定义多个OutputCache吗?为了前夫。假设我想将OutputCache副本存储在Server中,另一个存储在Client中。我知道我们可以用Location=OutputCacheLocation.ServerAndClient来实现这一点,但是如果我想为Client和Server指定不同的Duration,为Server设置更大的Duration,为Client指定更小的Duration呢?那么,有了这个要求,我可以按以下方式得到它吗?
[OutputCache(Duration = 3600, Location = OutputCacheLocation.Server, VaryByParam = "pID", NoStore = true)] //Server Cache for 1 hour
[OutputCache(Duration = 600, Location = OutputCacheLocation.Client, VaryByParam = "pID", NoStore = true)] //Client Cache for 10 minutes
public ActionResult GetDetails(string pID)
{
//some code
return View(model);
}这是有效的,让或MVC考虑到最新的OutputCache?
发布于 2016-03-19 17:51:35
如果查看OutputCacheAttribute的源,就会注意到该属性是用AllowMultiple属性设置为false定义的:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class OutputCacheAttribute : ActionFilterAttribute, IExceptionFilter所以这是行不通的
https://stackoverflow.com/questions/36104926
复制相似问题