0

I have a scenario where I need to change the HtmlPage.Window.CurrentBookmark property, but I want to do it without causing the Silverlight application to reload. Right now, I'm doing this, but it's causing the application to restart:

public void SetBookmark(string authenticationGroupTag, string ownerUserTag, string roomName)
{
    string bookmark = GetBookmark(authenticationGroupTag, ownerUserTag, roomName);
    HtmlPage.Window.CurrentBookmark = bookmark;
    // HtmlPage.Window.Eval("window.location.hash='" + bookmark + "'");
}

That particular behavior -- restarting the application -- doesn't seem to be documented anywhere, so I wonder if I'm just doing it wrong. I've tried catching various navigation related events (either Page.OnNavigatedFrom or RootFrame.Navigating), but neither of those actually get fired: the app just unloads and then reloads.

So I guess I have two parts to my question: (1) Is this the expected behavior, or am I just doing something wrong? and (2) If it is the expected behavior, has anyone come up with a workaround for it? Is there a way to update the portion of the URL after the "#" without reloading the Silverlight application?

Ken Smith
  • 20,305
  • 15
  • 100
  • 147

1 Answers1

0

Turns out that this is just a variant of a problem that's been long noted, namely, that Internet Explorer refreshes the page when (a) the user has arrived at the current page after a redirect, and (b) you change the window.location.hash. In other words, this is an IE issue (still not fixed in IE9!), not a Silverlight problem. Everything behaves correctly with Firefox and Chrome. (See javascript location.hash refreshing in IE and Response.Redirect with a fragment identifier causes unexpected refresh when later using location.hash for more details, and some suggested workarounds.)

Community
  • 1
  • 1
Ken Smith
  • 20,305
  • 15
  • 100
  • 147