Sessions variables in vb.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Where can I declare my application and session variables? I havn't found the
way to do this in VB except by declaring them "Public shared" in a class with
no constructor. Where is this done in most VB.net projects?

thank you for helping
 
Cedric FABIOUX said:
Hello,

Where can I declare my application and session variables? I havn't found
the
way to do this in VB except by declaring them "Public shared" in a class
with
no constructor. Where is this done in most VB.net projects?

Application and Session variables are not variables. You do not declare them
at all.

"Application" and "Session" are collection objects. "Application" is an
instance of the HttpApplicationState class, and "Session" is an instance of
the HttpSessionState class. Both classes have a property called Item, which
is an indexed property. This property can be indexed by the name of the
"variable":

Application.Item("varname") or
Session.Item("varname")

These can be abbreviated as

Application("varname") or
Session("varname")

You can set your "variable" with

Application("varname") = value or
Session("varname") = value


John Saunders
 
Back
Top