Is there any danger in using ConfigureAwait(false) in WebApi or MVC controllers?

前端 未结 4 1908
逝去的感伤
逝去的感伤 2021-01-31 07:43

Say I have two scenarios:

1) WebApi Controller

    [System.Web.Http.HttpPost]
    [System.Web.Http.AllowAnonymous]
    [Route(\"api/regi         


        
4条回答
  •  鱼传尺愫
    2021-01-31 08:10

    You may use ConfigureAwait on public action MVC Controller, it help to prevent deal lock if your _userService.GetAuthViewModelAsync keeps waiting. it cloud raise deadlock if async service keeps await so by may block httpcontext of UI.

    Have look below link to understand this case:

    http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

提交回复
热议问题