Calling Async Methods in Action Filters in MVC 5

前端 未结 2 1065
后悔当初
后悔当初 2021-02-19 11:47

I\'m writing an Action Filter (inheriting from ActionFilterAttribute) which uses HttpClient to POST data to an external server in the OnResultExe

2条回答
  •  抹茶落季
    2021-02-19 12:26

    Yes, it's still true. Web API 2 has support for async action filters, but MVC 5 still does not. I was just personally frustrated by this not too long ago. For the time being, you will either need to run your async method as sync inside the action filter, or repeat the async code that you would have had in an action filter inside each action that requires it, which you then can run as async.

提交回复
热议问题