Groups | Blog | Home
all groups > asp.net > may 2004 >

asp.net : Use Session in Module


Natty Gur
5/17/2004 8:47:26 PM
Hi,

module in OO world ?

anyway:
dim oSession as HttpSessionState = HttpContext.Current.Session

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377


*** Sent via Developersdex http://www.developersdex.com ***
The Clansman
5/17/2004 11:50:27 PM
Hi,
does anyone know how can I use the Session inside a module?? I tried

Dim Session As System.Web.SessionState.HttpSessionState

but I got an error......

thanks,
Bruno

matt
5/18/2004 8:31:20 AM
Assume you mean in an HttpModule....

You should note Session state is not available in the BeginRequest event
of an HttpModule, it will not have been loaded, session state is only
available after the AcquireRequestState event.

You can either choose to do your processing later, after the
AcquireRequestState event or you can implement an alternative strategy.
I have used HttpContext.Current.Cache and stored session data that is
required in the beginrequest event in a hashtable with each hashtable
indexed using the sessionID which can be retrieved from the session
cookie (HttpContext.Current.Request.Cookies["ASP.NET_SessionId"].Value).
I am sure this is not the ideal solution but it works well and solved me
no end of headaches!

HTH

Matt



"The Clansman" <Yeah! Send me spam!! I love it!! But send the porn
[quoted text, click to view]

Lau Lei Cheong
5/18/2004 11:44:56 AM
I think you should use httpsession.current.session instead...

"The Clansman" <Yeah! Send me spam!! I love it!! But send the porn ones....>
¦b¶l¥ó news:OzQWmLIPEHA.3944@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
[quoted text, click to view]

Darren Clark
5/18/2004 1:31:23 PM
check out

System.Web.HttpContext.Current.Session

or

System.Web.HttpContext.Current.Cache

etc



"The Clansman" <Yeah! Send me spam!! I love it!! But send the porn ones....>
[quoted text, click to view]

The Clansman
5/18/2004 3:29:38 PM
Thank you all for helping me!!

Bruno

"The Clansman" <Yeah! Send me spam!! I love it!! But send the porn ones....>
[quoted text, click to view]

AddThis Social Bookmark Button