I want to apply a filter before the OutputCache is applied.
I have this controller annotation
[OutputCache(Duration=3600,VaryByCustom="TypeOfDevice", Order=10)]
public ActionResult Index()
I defined the GetVaryByCustom
method in Global.asax
.
Also, I apply a filter of type ActionFilterAttribute
in Global.asax
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
// Register track filter
GlobalFilters.Filters.Add(new FrontEnd.Filters.MyFilter(), 0);
The first time MyFilter
is executed, but the following request do not reach the filter and the response comes from the OutputCache
.
How could I apply the MyFilter
before the OutputCache
.
Thanks in advance
Update:
MyFilter
is an ActionFilterAttribute
with the method override
public override void OnActionExecuting(ActionExecutingContext context)
{
// SET A COOKIE
base.OnActionExecuting(context);
}