c# - "Impersonating" session in a web service call -


i trying write web service returns session variables. application calls web service has access the session id of current session.

i tried doing creating "aspnet_sessionid" cookie , attaching setting cookie container of proxy class web service not work. did so,

 protected void callservice(string sessionid)     {         localhost.authservice auths = new localhost.authservice(); //service proxy class         system.net.cookiecontainer cookiejar = new system.net.cookiecontainer();           system.net.cookie newcookie = new system.net.cookie("aspnet_sessionid", sessionid);         newcookie.domain = "http://localhost";         cookiejar.add(newcookie);         auths.cookiecontainer = cookiejar;           string sessiondata = auths.getsessiondata(); 

the getsessiondata web method returns session data so:

[webmethod(enablesession=true)] public string getsessiondata(string sessionid) {return ((string)session["user"]);} 

should approach work, or doing wrong?

upd:this link solved problem - able access sessions inproc , able select correct 1 id:

http://weblogs.asp.net/imranbaloch/archive/2010/04/05/reading-all-users-session.aspx

"i trying enable third party application see user logged on website."

to achieve goal far better use asp.net membership on session track users.

then, see logged-in status can this:

bool isloggedin = membership.getuser("joe.user").isonline; 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -