I have a class Session.cs in the App_Code directory that needs to extract some values from the session. I define the session with this:
System.Web.SessionState.HttpSessionState session = HttpContext.Current.Session;
but when I run the page I get a Null Reference Exception on session.
The class (Session.cs) gets called from another .cs class. That gets in turn called by an aspx page.
Could it be that the session doesn't exist in the current part of the page cycle? The calling class gets called from page_load so it should exist.
How can I make sure that I reference the current session correctly? Thanks for reading.