'Proxy authentication with WebView21

Hello how can i set username and password of proxy automatically in my project with WebView21 in vb?

Here is my code: In this way the site makes me appear the popup to insert username and password of the proxy

        Dim options = New CoreWebView2EnvironmentOptions("--proxy-server=""IP-PROXY:PORT-PROXY""")
        Dim env = Await CoreWebView2Environment.CreateAsync(Nothing, Nothing, options)
        Await WebView21.EnsureCoreWebView2Async(env)
        Me.WebView21.Source = New Uri("https://www.google.com/")

But I want them to AUTOMATICALLY compile without the popup. I tried with this code but it doesn't work:

 Dim options = New CoreWebView2EnvironmentOptions("--proxy-server=""IP-PROXY:PORT-PROXY" & ":USERNAME:PASSWORD""")
    Dim env = Await CoreWebView2Environment.CreateAsync(Nothing, Nothing, options)
    Await WebView21.EnsureCoreWebView2Async(env)
    Me.WebView21.Source = New Uri("https://www.google.com/")

How can I do?

I found this solution but it is in C# (Autofill Proxy requirements webview2) and I don't know how to use it in visual basic.

    webView21.CoreWebView2.BasicAuthenticationRequested += new EventHandler<CoreWebView2BasicAuthenticationRequestedEventArgs>(delegate (object? sender, CoreWebView2BasicAuthenticationRequestedEventArgs e)
{
    var _credential = proxy == null ? null : proxy?.Credentials as NetworkCredential;
    if (_credential != null)
    {
        e.Response.UserName = _credential.UserName;
        e.Response.Password = _credential.Password;
     }
});

Can someone help me?

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source