Using Session in a class

  • Thread starter Thread starter Rock
  • Start date Start date
R

Rock

I have created several forms with procedures that I want to move to a class
so it can be used by other forms, but get an error when I move the Session
commands; e.g., Session("Mode")="Add"

How can I use Session in a class procedure.
 
HttpContext.Current.Session

Note however that HTtpContext.Current will be null if not in the a web
request context, safe programming would be:

dim context as HttpContext = HttpContext.Current
if context is nothing then
throw new ApplicationException("Must be used from within web context")
'or deal with it some other way
end if

dim session as HttpSessionState = context.Session
'can use session from here on end.

Karl
 
Back
Top