Execution Order of Mvc4 WebApi Action Filters

Nov 11, 2012 at 11:18 PM

There is no way to forecast the execution order of WebApi Action Filters. It changes randomly each time the code is changed. There is a patch for this here: http://www.strathweb.com/2012/06/control-the-execution-order-of-your-filters-in-asp-net-web-api/  however it cannot be applied to already existing filter such as the [Queryable] attribute. The result is that ...in practice one cannot apply more than a single filter since normally the output of a filter is the input of the one following it...and as we all know order of execution of code DO MATTER and cannot be changed.

My question is there will be a fix for this issue? 

It would be nice to have an integer property to control the order like in normal Mvc controllers ...but also respecting the order they are put on the action method would be accptable

Nov 12, 2012 at 4:12 PM

It's a reasonable request. It's also timely since we are in the middle of planning for our next version of ASP.NET Web API. My suggestion would be to add this request on the Web API UserVoice site so that the community can vote on it:


Daniel Roth