Monday, February 1, 2016

ASP.MVC: Async/Await in action filters

A colleague was having some trouble with his ASP.NET MVC 4 application. Whe he started his application, the process “hanged” and he had to kill the w3wp process to be able to restart.

We were able to pinpoint the problem to a call to an async method inside an Action Filter:

It seems that there is no support for async filters in ASP.NET MVC 4. The call to .Result in the action filter resulted in a blocking operation making the whole application pool unavailable. We solved it by switching to a non async version of the api.

Remark: Note that ASP.NET Web API does have support for async action filters.

No comments: