Introduction
In this article we will see how we can navigate to a default page when user logs
out in Silverlight 4 navigation framework.

Create Silverlight Application
Fire up Visual Studio 2010, and select Silverlight Business Application Project
from the templates. Name the solution as NavigationSample2.

Let's talk about requirements; a particular link should not be visible if a user
is not logged in and as soon as user logs out the link should not be visible.
And the user would be navigated to the Home page if logged out.
The above requirement is pretty simple. To achieve this let's add a page called
EmployeePage.xaml to the View.

Now add the link of the EmployeePage to the MainPage.xaml.

As you see in the above xaml display, the visibility of the Hyperlink Button is
made collapsed.
Now we would handle the LoggedIn and LoggedOut events of the RIA Authentication.
In MainPage.xaml.cs, we need to add the following in the constructor to achieve
our requirement.

As you see in the above Constructor, we have handled the Visibility of the link
button based on the Authentication.
If we run the application we can see the changes.

The above links are displayed when user hasn't logged in.

The above links are displayed when user logs in.
Now we would do the second part of the requirement, which is if user logs out it
would navigate to the Home Page.
As you can see in our requirement "EmployeePage" is the restricted Page and
restricted Link and other links are public. So we would handle the LoggedOut
event in EmployeePage's constructor.

As you see in the above code, it's very simple. We need to navigate to the
required page when user logs out.
Hope this article helps.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Former memberPosted Oct 10, 2013, 7:09 AM
http://www.dotnetpools.com/2013/06/simple-login-form-to-login-without.html
Zosimo recioPosted Oct 7, 2013, 9:02 PM
the code not working on me.. i user silverlight 5.. the hiden was not showing when login..
Vincent NyangaPosted Mar 8, 2013, 4:15 AM
Help me please. I want to create a temporary user account for a user if they meet a certain criteria say, for instance, if they book a venue
raj tPosted Dec 18, 2012, 8:39 AM
This loooks good but For Entry level silver light learners it is some how complicate
RobertPosted Feb 9, 2011, 3:07 PM
Thank you for this information. I looked for 6 hours trying to find this solution, and finally I have! Thanks so much!
Mike GoldPosted Jul 29, 2010, 3:33 PM
Might be worth mentioning the scope of this solution. For example, this will only work against an ASP.NET server set up with Authentication installed. I suspect this also requires that you have a SQL Server on the back end as well to store all the users.
Rafal StrozykPosted Jul 29, 2010, 6:53 AM
Problem is - unauthenticated user can still open the EmployeePage direct from browser adressbar http://localhost/NavigationSample2TestPage.aspx#/EmployeePage You need to check user authentication in MainPage.cs ContentFrame_Navigating or EmployeePage OnNavigatedTo event and redirect all unathorized users to login page.