views:

211

answers:

3

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?

+2  A: 

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.

James
Oh! What is that option's name? I'll try it.
FFire
This should help you out. http://msdn.microsoft.com/en-us/library/ms178194.aspx
James
+1  A: 

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

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

Abdullah Ahmed
FFire
A: 

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!

FFire
I would really like to see explanation of that! I tought that cookie and IsolatedStorage are the only way to store information about user between two sessions.
Hrvoje
I think they are the only way, but Ria services probably uses cookies to store the info for you.
James Cadd
I used fidller and saw that silverlight set coockies. But I think RIA is just read coockies correctly and fire IsAuthenticated in right way. I do not know the answer, it's only guess.
FFire