Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Navigation and Authentication service
    text
    copied!<p>I am creating a silver light application using Navigation app template. It is for internal use and hence uses windows authenticatoin. There is a dashboard page which shows couple of records filtered by logged in users id. To get the user id (which is an int) I call a web service by overriding the GetAuthenticatedUser and pass the username (from IPrincipal). This service takes some time to return the details.</p> <p>When I navigate to dashboard app, it renders completely with no data because the user service is a async operation and I am not able to make the rendering wait till my GetAuthenticatedUser finishes completely. So I created a Login page which just shows a progress bar till I get the user object and then navigate to dashboard. If someone tries to access the dashboard directly by using the URL, i want them to navigate back to Login page.</p> <p>So in the dashboard constructor I added the following code</p> <pre><code> if (!UserService.Current.User.IsAuthenticated) { MessageBox.Show("Navigating away"); Frame objContainer = this.Parent as Frame; objContainer.Navigate(new Uri("/Views/Login.xaml", UriKind.Relative)); } </code></pre> <p>Thogh I get the message box prompt, it does not actually take me to Login page but stays in dashboard page. I also tried putting this code in OnNavigatedTo override with no luck.</p> <p>I also tried using NavigationService instead of Frame as below, with no luck</p> <pre><code> if (!UserService.Current.User.IsAuthenticated) { MessageBox.Show("Navigating away"); this.NavigationService.Navigate(new Uri("/Views/Login.xaml", UriKind.Relative)); } </code></pre> <p>it still does not work. Does anyone know how to make some page accessible only if I have fully valid user object? if they try to access the restricted page without this, I want them to be able to redirected to Login page, how can this be achieved?</p> <p>I am using Silverlight 3 Beta</p> <p>Shreedhar</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload