有没有办法阻止WebView2启动Windows Network Diagnostics窗口?

发布于 2025-02-05 18:26:51 字数 406 浏览 3 评论 0原文

在我带有WebView2控件的WPF应用程序中,要求页面内的任何交互(例如单击链接)都不会启动任何外部窗口(即任何不属于应用程序的窗口)。

如果页面无法访问WebView2的加载或发生超时,则显示ERR_TIMED_OUT页面,并显示了运行Windows网络诊断的链接,如下所示。

单击“运行Windows网络诊断”链接时,它会启动MSDT.EXE。

有没有办法防止WebView2启动其他应用程序和MSDT.EXE(例如MSDT.EXE)?

In my WPF application with WebView2 control, it is required that any interaction (like clicking links) inside the page does not launch any external windows (i.e. any windows that is not part of the application).

In case a page the WebView2 is loading is not accessible or a timeout occurs, ERR_TIMED_OUT page is displayed with a link to run Windows Network Diagnostics as shown below.

ERR_TIMED_OUT

When clicking "Running Windows Network Diagnostics" link, it launches msdt.exe.

Is there a way to prevent WebView2 from launching other applications and windows like msdt.exe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬心 2025-02-12 18:26:52

您可以使用 corewebview2.settings.isbuiltinerrorpageEnabled disable in Indrore ofror Pages,然后在“ nofollow noreferrer”> code> code> core> core> core> core> core> core> core> core>并显示您自己的错误页面。

private async void InitializeWebView2Async()
{
    await WebView2.EnsureCoreWebView2Async();
    WebView2.CoreWebView2.Settings.IsBuiltInErrorPageEnabled = false;
    WebView2.NavigationCompleted += WebView2_NavigationCompleted;
}

private void WebView2_NavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
{
    if (!args.IsSuccess)
    {
        sender.NavigateToString("Navigation Failure: " + args.WebErrorStatus);
    }
}

You can use CoreWebView2.Settings.IsBuiltInErrorPageEnabled to disable built in error pages, and then in CoreWebView2.NavigationCompleted watch for errors and show your own error page.

private async void InitializeWebView2Async()
{
    await WebView2.EnsureCoreWebView2Async();
    WebView2.CoreWebView2.Settings.IsBuiltInErrorPageEnabled = false;
    WebView2.NavigationCompleted += WebView2_NavigationCompleted;
}

private void WebView2_NavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
{
    if (!args.IsSuccess)
    {
        sender.NavigateToString("Navigation Failure: " + args.WebErrorStatus);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文