小编use*_*173的帖子

HttpContext 在后台线程中丢失

我有一个异步方法,它使用 HttpContext.Current,它由另一个在后台运行的代码使用,例如

var result = Task.Run(async () => await SomeMethod()).Result;
Run Code Online (Sandbox Code Playgroud)

HttpContext.Current 始终为 null。有没有办法将 HttpContext 传递给后台任务?

c# asp.net httpcontext task-parallel-library async-await

0
推荐指数
1
解决办法
129
查看次数