ASP.Net MVC ignoring filter order
.net, action-filter, asp.net, asp.net-mvc, c#
Solution
You're overriding different parts of the cycle. `OnResultExecuting` (OnResultExecuting) in will happen before `OnResultExecuted` (CompressAttribute).
I would have to verify but this is where compression and output caching need to happen and so it may not even be an option to compress before you output cache. There may be a good reason beyond my ken for this.
Problem
Just wondering if anyone has any idea of why my filter order is being ignored... ``` [AcceptVerbs(HttpVerbs.Get)] [Compress(Order = 1)] [EnhancedOutputCache(Order = 2, Duration = 5, VaryByParam = "true", Location = OutputCacheLocation.ServerAndClient)] public virtual ActionResult Index() { return View(); } public class CompressAttribute : ActionFilterAttribute { public override void OnResultExecuted(ResultExecutedContext filterContext) { base.OnResultExecuted(filterContext); } } public class EnhancedOutputCacheAttribute : OutputCacheAttribute { public override void OnResultExecuting(ResultExecutingContext filterContext) { base.OnResultExecuting(filterContext); } } ``` In this case, the EnhancedOutputCache is being run before Compress is... I want the compression to happen first but its running second... any ideas why As a side note I'm using ASP.Net MVC 2.0 preview 1...