且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

异步设置 Thread.CurrentPrincipal ?

更新时间:2023-12-03 18:54:46

您还必须设置 HttpContext.Current.User.请参阅此答案这篇博文 了解更多信息.

You have to set HttpContext.Current.User as well. See this answer and this blog post for more info.

更新:还要确保您在 .NET 4.5 上运行并将 UserTaskFriendlySynchronizationContext 设置为 true.

Update: Also ensure you are running on .NET 4.5 and have UserTaskFriendlySynchronizationContext set to true.