Managing Navigation Exceptions

Hello,

In my wpf app I have a frame [MyFrame]. I dynamically change the content of the frame by navigating to different pages [MyFrame.Navigate(somePageURI);].

I want to make sure that I can handle situations where navigation fails. For example, the uri points into noWhere, or the user doesn't have permissions to read the content pointed to by somePageURI.

If I'm not mistake the Navigate method is asynchronous. So I can't do the following:

try {MyFrame.Navigate(somePageURI)} Catch(IOException ioe) {HandleNavigationException(ioe);}

I tried to register a handler with my frame to handle navigation events, but I don't seem to find an event one for navigation error.

Thanks in advance.

Houman

[748 byte] By [Houmanb] at [2007-12-24]
# 1
there is NavigationFailed event on the navigation window that occurs when an error is encountered while navigating to the requested content
leed at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Hi Lee,

Thanks for the response...but, I can't fine a nviagtionFailed on the Frame, Window or NavigationServices...

My Window is derived from System.Windows.Window.

It is not a NavigationWindow.

Thanks

Houman

Houmanb at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

I'm having the same problem.
For the time being I'm using "Application.Current.DispatcherUnhandledException" as a workaround.

Best regards,
Thomas Andersen

ThomasS.Andersen at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4

Hi Houman,

The RC1 download for the .NET Framework 3.0 should have the NavigationFailed event on the Application, Frame, NavigationWindow classes. Which version do you have installed? If you don't already have it, you might want to upgrade to RC1 so you can register a NavigationFailed event handler on your app so it will be able to gracefully handle the cases where errors occur after you've called the Navigate method.

Please note that the NavigationFailed event gets fired for WebExceptions and IOExceptions only, so you may still need to use the Application class's DispatcherUnhandledException event and write your own eventhandler if there are other types of exceptions that you want your application to handle (without crashing the app).

Thanks,

Karen

KarenFranco-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5

Hello Karen,

That's great news! Exactly what I want.

I'm still using the June CTP. I haven't switched over because I'm worried that I might loose a day or two of development :(

Is Ocra available for the RC1?

Thanks

Houman

Houmanb at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 6

Hi Houman,

Glad to hear that was helpful! It looks like the Orcas Preview will be available some time this week. Check out Rob Relyea's post at: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=691357&SiteID=1

thanks,

Karen

KarenFranco-MSFT at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified