Adding support for controller-level OutputCacheAttribute to OutputCacheFilter.

This commit is contained in:
Daniel Stolt
2013-09-05 19:13:54 +02:00
parent cf5714b2f8
commit 13af4c3f6d

View File

@@ -88,7 +88,9 @@ namespace Orchard.OutputCache.Filters {
_actionName = filterContext.ActionDescriptor.ActionName;
// apply OutputCacheAttribute logic if defined
var outputCacheAttribute = filterContext.ActionDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true).Cast<OutputCacheAttribute>().FirstOrDefault();
var actionAttributes = filterContext.ActionDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true);
var controllerAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true);
var outputCacheAttribute = actionAttributes.Concat(controllerAttributes).Cast<OutputCacheAttribute>().FirstOrDefault();
if (outputCacheAttribute != null) {
if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore) {