How to access HTTPContext in ASP.NET Core?
ASP.NET Core apps use the IHttpContextAccessor interface and its default implementation HttpContextAccessor to access HttpContext. IHttpContextAccessor is only required when you need access to the HttpContext within a service.