public static HttpContext GetContext()
{
HttpContextAccessor context = new HttpContextAccessor();
return context.HttpContext;
}
为何实例化HttpContextAccessor 就直接能获取到当前请求上下文?
盲猜其上下文是个单例
它是从当前的线程上下文中获得httpconext.
https://github.com/dotnet/aspnetcore/blob/master/src/Http/Http/src/HttpContextAccessor.cs