is this a bad practice
is it bad to access httpcontext directly? what is the alternative?
2 Replies
should be fine depending on the context, i.e. if you're in a controller. you can also inject the IHttpContextAccessor through DI if you want an alternative
Access HttpContext in ASP.NET Core
Learn about using HttpContext in ASP.NET Core apps. HttpContext isn't thread-safe and can throw an exception when accessed.