I'm creating a custom internet browser using winforms and webview2 and whenever I search for something when using say a school internet it has a proxy box asks for my username and password. How can I autofill this box every time it opens
0
votes
Ideally you should be able to the proxy in options, but it doesn't seem to have been fixed yet: github.com/MicrosoftEdge/WebView2Feedback/issues/…
- Poul Bak
Is the dialog that pops up a javascript dialog?
- Poul Bak
not completely sure if its Javascript, It only pops up if I 1. Haven't connected to that internet today. or 2. I reconnected to it.
- Redstone145
1 Answers
0
votes
There are command-line options for proxy settings. You can set those options through AdditionalBrowserArguments property of an instance of CoreWebView2EnvironmentOptions and pass to CoreWebView2Environment.CreateAsync when creating the CoreWebView2.
For example:
WebView2 webView21 = new Microsoft.Web.WebView2.WinForms.WebView2();
private async void Form1_Load(object sender, EventArgs e)
{
var options = new CoreWebView2EnvironmentOptions();
options.AdditionalBrowserArguments = "--proxy-server=\"proxyhostname:8000\"";
var env = await CoreWebView2Environment.CreateAsync(null, null, options);
await webView21.EnsureCoreWebView2Async(env);
webView21.Dock = DockStyle.Fill;
this.Controls.Add(webView21);
webView21.Source = new Uri("Https://stackoverflow.com");
}
Here are the options that you can use:
--no-proxy-server: Not to use proxy.--proxy-auto-detect: Automatically detect proxy configuration.--proxy-server=<scheme>=<uri>[:<port>][;...] | <uri>[:<port>] | "direct://": Use custom configurations.--proxy-bypass-list=(<trailing_domain>|<ip-address>)[:<port>][;...]: Bypass any specified proxy for the specified semicolon-separated list of hosts.--proxy-pac-url=<pac-file-url>: To use the PAC file at the specified URL.
To see more description and example about those options see: