Obtaining Session ID from within a class library?

  • Thread starter Thread starter Ben Fidge
  • Start date Start date
B

Ben Fidge

I've split my application up into an ASP.NET project and several class
library dlls. From within these dll's I want to write information to a log
file, and each line needs to have the session id recorded.

Is it possible to get the session id of the calling page, from within a
method in a class in one of the dlls, without passing it as a parameter?

Thanks

Ben
 
Assuming that the class is operating in the context of an HTTP Request for
an ASPX page, you can access the Session via
System.Web.HttpContext.Current.Session.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
you should use HttpContext.Current.

That will give you access to the context of current request. you can then
access HttpContext.Current.Session object.

--

Regards,

Hermit Dave (D'way)
http://hdave.blogspot.com

(I hear what you're saying.. but lets try it my way first)
 

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