A1exandr Belan
A1exandr Belan

Reputation: 4780

How to make user persist between sessions?

I use Silverlight Business Application (Application with RIA Services). Create new project. All setting by default.Compile and run it. In application I create new user. It's all right. Then I add a chackbox to LoginWindow.xaml:

<CheckBox x:Name="isPersistent" Content="Remember me"/>

and modify LoginButton_Click method.

    private void LoginButton_Click(object sender, RoutedEventArgs e)
    {
        SetEditableState(false);
        var parameters = new LoginParameters(loginUserNameBox.Text, 
                                             loginPasswordBox.Password, 
                                            (bool)isPersistent.IsChecked);
        UserService.Current.Login(parameters);
    }

But when I login and chek the "Remember me" CheckBox - user is not persist between sessions.

What I'm doing wrong? How I can make user persist between sessions?

Upvotes: 2

Views: 449

Answers (3)

A1exandr Belan
A1exandr Belan

Reputation: 4780

Solution was easy: By default Silverlight Business Application generate .aspx with asp:Silverlight control insted ria:SilverlightApplication.

So, I add in .aspx:

<%@ Register Assembly="System.Web.Ria" 
 Namespace="System.Web.Ria" TagPrefix="ria" %>

and replace asp:Silverlight control by

<ria:SilverlightApplication ID="Silverlight1" runat="server"
Source="~/ClientBin/BusinessApplication1.xap" MinimumVersion="3.0.40305.0"
Width="100%" Height="100%" />

It works!

Upvotes: 0

Abdullah Ahmed
Abdullah Ahmed

Reputation: 510

Have you looked into IsolatedStorage? If you want to use cookies then this thread might help.

http://silverlight.net/forums/p/11969/38621.aspx

Upvotes: 1

James
James

Reputation: 82136

Not really sure with regards to Silverlight, however, in an ASP.NET you would just set the expiration days of the cookie depending on how many days you wish to remember the user.

James.

Upvotes: 2

Related Questions