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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priya LingePosted Jul 22, 2011, 1:16 AM
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.
Priya LingePosted Aug 2, 2011, 2:40 AM
Please see attached file ,i have written your code in this application.
Thanks.
nagarajuPosted Aug 2, 2011, 2:06 AM
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
Soft CornerPosted Jul 22, 2011, 2:09 AM
Thank you so much ,, that works for me :)
Jaganathan BantheswaranPosted Jul 21, 2011, 9:48 AM
Have you tried yourself ? Are you getting error ? If so what is the error you got?