Using Session, Response etc. in a class

  • Thread starter Thread starter Jakob Bengtsson
  • Start date Start date
J

Jakob Bengtsson

Hi,

I'm building an ASP .NET application. I have a routine to
check some info in an object stored in a Session variable.

As it is, I have to duplicate this code in every page.

Is there any way to build a class which can access the
info stored in a session variable?

I would like to build a class containing methods, which I
can call from my web pages. This class will read, for
instance, Session("info"), and perform some routines
based on the data.

I can build the class, and make it
inherit "System.Web.UI.Page", in order to get this
functionality, but is there no better way? There really
seems to be no need to inherit all the functionality of a
page (it clutters Intellisense, if nothing else)!?

Any help is appreciated.

Regards,
Jakob
 
Hi Kevin,

That was a big help -- thanks alot!!

Regards,
Jakob
-----Original Message-----
You can grab all objects that are available in a Page from the Current
HttpContext. Example:

Dim objSession as
System.Web.SessionState.HttpSessionState =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top