Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
Hi,

I tried to manage user session in silverlght application, the classe session doesn't exsit!!! how can manage user session in silverlight???
thx
Posted
Comments
Sunasara Imdadhusen 22-Nov-10 6:33am    
Good question!

 
Share this answer
 
Comments
Dalek Dave 22-Nov-10 7:31am    
Good Link.
souidi abderrahman 22-Nov-10 8:34am    
it is in vb language.there is a code in c#??
senguptaamlan 22-Nov-10 8:49am    
a handy tool to convert VB code to C#

http://www.developerfusion.com/tools/convert/vb-to-csharp/
Silverlight does not directly support sessions.
You can make use of Isolated Storage though - see here[^].
 
Share this answer
 
XML
Now I created Method in Wcf service like this:
<pre>
<pre lang="cs">[ServiceContract(Namespace = &quot;&quot;)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
    [OperationContract]
    public void DoWork()
    {
        // Add your operation implementation here
        return;
    }
    // Add more operations here and mark them with [OperationContract]
    [OperationContract]
    public void SetSessionVariable(string SessionKey)
    {
        System.Web.HttpContext.Current.Session[&quot;key&quot;] = SessionKey;
        System.Web.HttpContext.Current.Session.Timeout = 20;
        // Add your operation implementation here
    }
    [OperationContract]
    public String GetSessionvariable()
    {
        return System.Web.HttpContext.Current.Session[&quot;key&quot;].ToString();
    }</pre>
</pre>
and update the service in the client side application and write the following code in the login page:
<pre>
wcfService.Service1Client client = new wcfService.Service1Client();
client.GetSessionvariableCompleted += new System.EventHandler&lt;wcfService.GetSessionvariableCompletedEventArgs&gt;(client_GetSessionvariableCompleted);
           client.GetSessionvariableAsync();</pre>
<pre lang="cs">void client_GetSessionvariableCompleted(object sender, wcfService.GetSessionvariableCompletedEventArgs e)
        {
        }</pre>
</pre>
i had an exeption in the wcf service at the method GetSessionvariable asking me Object reference not set to an instance of an object.
i need to get the session key from the method GetSessionvariable!!!
someone can help me please??????????
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900