HI,
how can i store session in WCF for silverlight application?
Note : session is going to store by some another asp.net application in wcf & later silverlight apps is going to use this
session from same wcf.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Priya LingeRank #785 · 2.9K reputationPosted Jul 21, 2011, 9:16 PM EDT
You can store the session in WCF like following way,
First you need to put this attribute on your WCF Sevice class: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]:
1.While setting session value ,
System.Web.HttpContext.Current.Application.Add(SessionKey,Sessionvalue);
OR
System.Web.HttpContext.Current.Session[SessionKey]=Sessionvalue;
2.While getting session value,
return System.Web.HttpContext.Current.Application.Get(SessionKey);
OR
return System.Web.HttpContext.Session[SessionKey];
Please see the below link.
http://bursjootech.blogspot.com/2008/09/how-to-use-sessions-in-wcf-and.html
http://www.codeproject.com/KB/silverlight/SilverlightASPNetSessions.aspx
Please see the attached file.
Thanks.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jul 21, 2011, 5:48 AM EDT
Have you tried yourself ? Are you getting error ? If so what is the error you got?
Soft CornerRank #1,221 · 1.5K reputationPosted Jul 21, 2011, 10:09 PM EDT
Thank you so much ,, that works for me :)
nagaraju84 reputationPosted Aug 1, 2011, 10:06 PM EDT
public object SetSessionVariable(string key, string value)
{
System.Web.HttpContext.Current.Session[key] = value;
string x = System.Web.HttpContext.Current.Session.SessionID.ToString();
return (string)System.Web.HttpContext.Current.Session[key] + " " + x;
}
Thanks&Regards
Nagaraju.p
Priya LingeRank #785 · 2.9K reputationPosted Aug 1, 2011, 10:40 PM EDT
Please see attached file ,i have written your code in this application.
Thanks.