Async action filter in MVC 4

You cannot have async filters, but you can have async event handlers.

An async event handler can do the heavy async work, write to HttpApplication.HttpContext.Items, and then your sync filter can post-process or verify the results.

You can either register event handlers in Global.asax.cs, or create and register a HTTP module.

(All filters are executed between the PreRequest and PostRequest events.)


MVC does not have an async-compatible action filter (but WebAPI does have one).

For now, I recommend you use blocking calls in OnActionExecuting. Hopefully MVC will have a better story in the future.

Update: You can vote here for the MVC team to add async filters.