Re: Sessions variables in vb.net by John
John
Tue Dec 14 10:02:34 CST 2004
"Cedric FABIOUX" <CedricFABIOUX@discussions.microsoft.com> wrote in message
news:B619A016-44D3-455C-9FD1-F34ABC9A4D81@microsoft.com...
> 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