public void OnActionExecuting(ActionExecutingContext context) { ArgumentNullException.ThrowIfNull(context); // If there are more filters which can override the values written by this filter, // then skip execution of this filter. var effectivePolicy = context.FindEffectivePolicy <IOutputCacheFilter>(); if (effectivePolicy != null && effectivePolicy != this) { Log.NotMostEffectiveFilter(_logger, GetType(), effectivePolicy.GetType(), typeof(IOutputCacheFilter)); return; } var outputCachingFeature = context.HttpContext.Features.Get <IOutputCacheFeature>(); if (outputCachingFeature == null) { throw new InvalidOperationException( Resources.FormatOutputCacheAttribute_Requires_OutputCachingMiddleware(nameof(OutputCacheAttribute))); } }