Reputation: 719
I am trying to write a web service in ASP.NET which enables an outside application to access Session Variables such as the users that is currently logged in.
I thought that a correct way to do so would be to pass a cookie with a SessionID to the web service (or the SessionID itself), and have the web service return parameters of the Session object.
However, after a prolonged search I could not find a way to access Session variables with just a SessionID. Is this true? If so, is there an alternative way for me to write a service that will access session variables?
Thank you,
Upvotes: 3
Views: 1777
Reputation: 10623
Do you have attribute [WebMethod(EnableSession = true)]
for your web method?
Session Variables and Web Services
Also, you can do Cookieless Sessions.
http://msdn.microsoft.com/en-us/library/aa480509.aspx
Upvotes: 1
Reputation: 41685
Off-hand, if you're using SQL session storage you could just query the session database by session id...
select
s.[SessionItemShort]
,s.[SessionItemLong]
from [ASPStateTempSessions] as s
where s.[SessionId] = @sessionId
iirc, SessionItemShort is a varbinary while SessionItemLong is an image... if the session item is larger than a varbinary(7000) it'll get stored in SessionItemLong instead.
Upvotes: 0