As JHOutputCache
extends OutputCacheAttribute
, which derives from ActionFilterAttribute
, halting execution of the underlying action is quite simple:
public class JHOutputCacheAttribute : OutputCacheAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (condition)
filterContext.Result = new EmptyResult();
else
base.OnActionExecuting(filterContext);
}
}
You can return any valid ActionResult here, including any custom ActionResult
you may have derived.