Making an async call in an MVC 5 action filter

前端 未结 1 1810
面向向阳花
面向向阳花 2021-01-17 09:55

The problem

I have an api GET method to retrieve site configuration. I am using httpClient and the GetAsync() method to d

相关标签:
1条回答
  • 2021-01-17 10:33

    There is no way to (reliably) call an asynchronous method from an ASP.NET MVC 5 action filter. This has already been fixed in ASP.NET vNext, but AFAIK there are no plans to support this in MVC 5.

    If you absolutely must do this in an action filter, then you must use synchronous calls (e.g., WebClient instead of HttpClient).

    0 讨论(0)
提交回复
热议问题