Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear navigation history in Silverlight/Windows Phone 7?

I'm making a Windows Phone 7 app that has login/logout semantics (authenticating to a web app). When the user logs out I navigate back to the login screen and forget the session authentication.

When doing so I'd also like to clear the navigation history so that can't go back to a page that expects them to be already authenticated.

Can't see how to do it with NavigationService and am wondering if there is a way to do this.

like image 655
dkackman Avatar asked Oct 22 '10 22:10

dkackman


2 Answers

There are a few things to look at here. First is I recommend familiarising with the guidance offered here.

Introducing the concept of “Places” - Peter Torr's Blog

Redirecting an initial navigation - Peter Torr's Blog (down at the moment sorry)

If you're able to work within this guidance that is the best path. There is specific advice for dealing with login screens.

If you are compelled to offer a home button feature. Be careful how you apply this, as certifiers are knocking apps back for behaving in unexpected ways with respect to navigation. I feel if this function is behind a home button you should be ok in the surprise department. How this stands over time with certification we will see. Arguably a "logout" scenario applies equally.

Here are three approaches from Richard Woo, Maarten Struys, Sam Jarawan.

like image 136
Mick N Avatar answered Nov 09 '22 23:11

Mick N


This code works well (it needs to be in your page), haven't tried to get it past certification yet but the code does work:

 while (true)
 {
     if (this.RemoveBackEntry() == null)
     {
         break;
     }
  }

This does seem to differ with the documentation, which says an exception will be raised when there is no more items so I have logged a bug on user voice for this, so it may change in future.

like image 38
Robert MacLean Avatar answered Nov 10 '22 01:11

Robert MacLean