Reputation: 4182
I would like to make a test , first of all redirecting to a blank page and then just after redirecting to a normal page, but it looks like it doesnt make the second redirect ...
Browser.Base = Constants.ParkInfoDirectory; // "ParkInfo" folder
string s = string.Format("{0}/section_{1}.html", _parkId, _parkPage);
// URL = "/ParkInfo/ti217/5" for page 5 of Rainier
string blank = string.Format("{0}/Blank.html", _parkId);
Browser.Navigate(new Uri(blank, UriKind.Relative));
this.Browser.UpdateLayout();
Browser.Navigate(new Uri(s, UriKind.Relative));
this.Browser.UpdateLayout();
New version :
string s = string.Format("{0}/section_{1}.html", _parkId, _parkPage); // URL = "/ParkInfo/ti217/5" for page 5 of Rainier
string blank = string.Format("{0}/section_blank.html", _parkId);
Uri blank_ = new Uri(blank, UriKind.Relative);
Browser.Navigate(new Uri(blank, UriKind.Relative));
Browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(Browser_Navigated);
{
if (e.Uri == blank_)
{
Browser.Navigate(new Uri(s, UriKind.Relative));
}
};
Browser.Navigate(blank_);
Upvotes: 0
Views: 1761
Reputation: 8126
You call two navigate method in one UI thread
execution. It can cause some issues with that. Try to put second Navigate
inside Dispatcher
to delay it execution or subscribe to Navigated
event and call second Navigate
from it
Browser.Navigate(new Uri(blank, UriKind.Relative));
Dispatcher.BeginInvoke(() =>
{
Browser.Navigate(new Uri(s, UriKind.Relative));
});
Or:
Uri blank_ = new Uri(blank, UriKind.Relative)
Browser.Navigated += (s, e) =>
{
if (e.Uri == blank_)
{
Browser.Navigate(new Uri(s, UriKind.Relative));
}
};
Browser.Navigate(blank_);
Upvotes: 2