i get an error when i try to access HttpContext.Current from a controller.
I want to get the session to add some session specific data, and this gives me a problem:
var a = HttpContext.Current.Session;
The error, allegedly is that ‘System.Web.HttpContextBase’ does not contain a definition for ‘Current’.
You should never use
HttpContext.Current.Simply use the
Sessionproperty to access the session:The reason for the error you are getting is because the controller class already has a property called HttpContext so when you write
HttpContext.Currentit is the property that is used and not the staticCurrentproperty on theHttpContextclass.