Calling ConfigureAwait from an ASP.NET MVC Action

前端 未结 3 1572
Happy的楠姐
Happy的楠姐 2021-02-19 01:45

I was working on a presentation and thought the following should fail since the ActionResult isn\'t being returned on the right context. I\'ve load tested it with VS and got no

3条回答
  •  你的背包
    2021-02-19 02:35

    In your code, HttpContext is a member of your AsyncController base class. It is not the current context for the executing thread.

    Also, in your case, HttpContext is still valid, since the request has not yet completed.

    I'm unable to test this at the moment, but I would expect it to fail if you used System.Web.HttpContext.Current instead of HttpContext.

    P.S. Security is always propagated, regardless of ConfigureAwait - this makes sense if you think about it. I'm not sure about culture, but I wouldn't be surprised if it was always propagated too.

提交回复
热议问题