Home All Groups Group Topic Archive Search About

Referring to Session in a Class

Author
7 Jun 2006 12:14 PM
page77.office
Trying to use Session(vars) in a Class so I can persist their access
across, mypages for the session.  File is Class1.vb

In a WebForm 'Session' is available but in a Class it is not I have to
precede 'Session' with

System.Web.HttpContext.Current.Session(Var)

similarly for 'response' (testing only - I promise)

Is it possible to refer to 'Session' without the full reference.

I have tried various Inherits and Imports but none successful too date

Thanks

Author
7 Jun 2006 2:44 PM
Kevin Spencer
HttpContext.Current.Session will do it.

You have to reference HttpContext, because that is the class in Current is a
member. Session is a member of Current. You shouldn't have to reference
System.Web.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

<page77.off***@googlemail.com> wrote in message
Show quote
news:1149682492.756443.168120@j55g2000cwa.googlegroups.com...
> Trying to use Session(vars) in a Class so I can persist their access
> across, mypages for the session.  File is Class1.vb
>
> In a WebForm 'Session' is available but in a Class it is not I have to
> precede 'Session' with
>
> System.Web.HttpContext.Current.Session(Var)
>
> similarly for 'response' (testing only - I promise)
>
> Is it possible to refer to 'Session' without the full reference.
>
> I have tried various Inherits and Imports but none successful too date
>
> Thanks
>

AddThis Social Bookmark Button