开发者

ASP.NET - Accessing Session Variables from an outside application

开发者 https://www.devze.com 2023-03-04 16:54 出处:网络
I am trying to write a web service i开发者_开发问答n ASP.NET which enables an outside application to access Session Variables such as the users that is currently logged in.

I am trying to write a web service i开发者_开发问答n 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,


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号