Virtual Happy Hour is canceled this month (March) due to Good Friday.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour is canceled this month (March) due to Good Friday.
You should be using IHttpContextAccessor, so the former is preferred. The best way is still making your class not static if possible.
I'm working my way through an Opti CMS 11 > 12 upgrade. I do not have my entire solution building yet but I have run into a few cases where I need to access the HttpContext in static instances.
First off, I have registered the IHttpContextAccessor in my services collection with the built in AddHttpContextAccessor() extension method.
Because of that, I'm thinking I can inject it like so:
However, I've read that I could also create a field and then initialize it like so in the constructor:
Are their any benefits/drawbacks to either approach? Like I said above, I don't have my upgrade running yet so apologies if one option doesn't even work.