UWP Webview NavigationStarting event handler is not working when URL is not Valid


Subscribe EvenHandler:

wv.NavigationStarting += webView_NavigationStarting;

EvenHandler Implementation

private static void webView_NavigationStarting(object sender, WebViewNavigationStartingEventArgs args)
    var url = args.Uri.AbsoluteUri.Substring(args.Uri.AbsoluteUri.LastIndexOf("/") + 1);
    int parameterCount = url.Split('_').Length;

When URL is valid it navigates perfectly fine, otherwise EvenHandler was not called.

And the pop up below shows:

enter image description here





You can use the WebView.UnsupportedUriSchemeIdentified event to handle unknown uri’s.

private void webView_OnUnsupportedUriSchemeIdentified(WebView sender, WebViewUnsupportedUriSchemeIdentifiedEventArgs args)
    args.Handled = true;

    // up to you what to do with args.Uri

Be aware that if the link is invalid, the WebView.NavigationFailed will be raised instead!


[], [], [], []

Facebook Comments

Website Comments

  1. fundraiser bracelets

    It’s actually a nice and useful piece of info. I am happy that you simply shared this helpful
    info with us. Please stay us informed like this. Thank
    you for sharing.

Post a comment