Someone in the post here commented that you should not use HttpContext.Current when using MVC, rather you should use ControllerBase.ControllerContext . In some respects, this makes sense, but in other respects it is not.
For example, ControllerContext is an instance variable, so wherever I want to reference, say, my session variables, do I need to have a reference to the controller? Why do we not โassumeโ to use HttpContext.Current in MVC when you can still? Is there a โsuitableโ MVC โpathโ to access my Session object without having to have a reference to the controller?
I know the test-wise, this is better for the reasons outlined in many other places, but I'm working on a project that manages session variables and HttpContext.Current links and I want to know if there is a better way to get my hands on a Session object, not passing the link to the controller.
gangelo
source share