I read a comment from an answer to Session variables in ASP.NET MVC. It is recommending to use HttpSessionStateWrapper
and HttpSessionStateBase
as opposed to using session directly as follows: Session["MyValue"]
:
If ASP MVC is being used then it is preferable to not use the actual Session object from HttpContext.Current.Session but to use the new HttpSessionStateWrapper & HttpSessionStateBase from System.Web.Abstractions.dll then use a Factory or DI to get the Session.
Can someone provide an MVC example of using these two aforementioned classes to initialize, retrieve, and set session variables ?