How to handle WPF WebBrowser control navigation exception

前端 未结 4 1859
慢半拍i
慢半拍i 2020-12-11 16:13

Let\'s say that WPF WebBrowser control shows some navigation errors and the page is not showing.

So there is an exception of WPF WebBrowser contro

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 16:54

    It is also possible to use dynamic approach here.

    wb.Navigated += delegate(object sender, NavigationEventArgs args)
            {
                dynamic doc = ((WebBrowser)sender).Document;
                var url = doc.url as string;
                if (url != null && url.StartsWith("res://ieframe.dll"))
                {
                    // Do stuff to handle error navigation
                }
            };
    

提交回复
热议问题