Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions, threads...how to identify a session without the session.

Status
Not open for further replies.

SBGibson

Programmer
Apr 18, 2001
125
IT
Hi guys,

I'm developping a static class library that can be consumed by winforms apps and web apps.
In one of the methods I would like to identify the user without accessing to the httpcontext (that doesn' exists in a win app) and without passing any parameter to the method.
I thought to use the CurrentThread.GetHashCode() but a new thread is created every connection, not every session so every session of the same user have the same thread ID.
You have some idea about how to distinguish a session?
I can try/catch the access to the http context in order to distinguish a web app from a win app but is not very elegant.
Some help? Thanks

Stevie B. Gibson
 
Not sure if I can help or not, but I can say that instead of the try/catch you could just use
Code:
if(System.Web.HttpContext.Current == null){
   //winforms
}else{
   ///webforms
}


Current context will be null during design time in web form, too.





Greetings,
Dragonwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top