NavigationService.NavigationFailed Event

Definition

Occurs when an error occurs while navigating to the requested content.

C#
public event System.Windows.Navigation.NavigationFailedEventHandler NavigationFailed;

Event Type

Examples

The following example shows how to handle NavigationFailed.

C#
void NavigationService_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
    string msg = string.Format("Navigation to {0} failed: {1}.", e.Uri.OriginalString, e.Exception.Message);
    this.progressStatusBarItem.Content = msg;
}

Remarks

When either a WebException or an IOException is thrown during a navigation, the NavigationFailed event is raised. NavigationFailed is passed a NavigationFailedEventArgs that encapsulates information about both the exception and the details of the navigation that caused the exception.

When an exception results from a failed navigation, and is unhandled, the following events are raised in the order listed:

If a navigator (NavigationWindow, Frame) is hosted by one or more navigators, NavigationFailed is not raised on any of them.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also