Open igotbass opened 4 years ago
There's a CoreWebView2.ProcessFailed event and a CoreWebView2Settings.IsBuiltInErrorPageEnabled property for dealing with WebView2 process crashes.
Great feature request! We don't currently have a way to change the proxy. When you say per application, do you mean changing the proxy settings for the group of WebView2s used by an application? I'll add it as a feature request. Thanks.
There's a CoreWebView2.ProcessFailed event and a CoreWebView2Settings.IsBuiltInErrorPageEnabled property for dealing with WebView2 process crashes.
Great feature request! We don't currently have a way to change the proxy. When you say per application, do you mean changing the proxy settings for the group of WebView2s used by an application? I'll add it as a feature request. Thanks.
Yes check the link I sent, its to set all the webbrowsers within the host application for my case its c#, this way u were always able to control the proxy settings per app rather than use fiddlercore as a "System" proxy therefore affecting all web traffic on that windows session.
@david-risney Do you already have a plan for this proxy feature? We have a requirements to use proxy in our application too, is that possible to use this new proxy feature in the next 1 or 2 months? Thank you.
@alexchx we have a similar requirement for setting a proxy for the process. We haven't gotten to test it yet but it seems like setting --proxy-server or --proxy-pac-url in the AdditionalBrowserArgument when creating the CoreWebView2EnvironmentOptions should work.
WebView2 _webView2 = new WebView2();
CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions();
// Set a proxy pac for the browser
// options.AdditionalBrowserArguments = "--proxy-pac-url=http://myproxy.com/my.pac";
// Set the proxy for the browser
options.AdditionalBrowserArguments = "--proxy-server=\"foopy:99\"";
// Create the environment manually
CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, options);
await _webView2 .EnsureCoreWebView2Async(env);
@michael-russin Thanks a lot, this approach worked well đź‘Ť
@alexchx we have a similar requirement for setting a proxy for the process. We haven't gotten to test it yet but it seems like setting --proxy-server or --proxy-pac-url in the AdditionalBrowserArgument when creating the CoreWebView2EnvironmentOptions should work.
WebView2 _webView2 = new WebView2(); CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions(); // Set a proxy pac for the browser // options.AdditionalBrowserArguments = "--proxy-pac-url=http://myproxy.com/my.pac"; // Set the proxy for the browser options.AdditionalBrowserArguments = "--proxy-server=\"foopy:99\""; // Create the environment manually CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, options); await _webView2 .EnsureCoreWebView2Async(env);
This doesnt work. How can I use proxy settings in WebView2?
@Birol2010 For the proxy server, I think you might have to change it to something else, for example 127.0.0.1:8888
, also I'm using the WPF version of WebView2, are you using the same?
@Birol2010 For the proxy server, I think you might have to change it to something else, for example
127.0.0.1:8888
, also I'm using the WPF version of WebView2, are you using the same?
Thanks your replay
I use Winforms version. EnsureCoreWebView2Async method doesnt work. Because Webview2 has initialized already when we call EnsureCoreWebView2Async. So CoreWebView2Environment doesnt apply the initialized Webview2 object.
Best regards.
@Birol2010 You'll need to comment out or remove the Source property in the designer InitializeComponent() call. Otherwise, setting the source property will kick off initialization.
I have the same issue, but I'm not using C/C++. I tried to create the CoreWebView2EnvironmentOptions
, as a COM-like, but doesn't work.
The alternative is to set the WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
environment variable. Of course, you can set the variable to just your own application.
In golang, which I'm using:
os.Setenv("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", fmt.Sprintf(`--proxy-server="%s"`, "192.0.0.1:7777"))
Regardless of the language used, you can set the environment variable and, in this case, set the proxy.
@Inkeliz Your alternative works fine !
@alexchx we have a similar requirement for setting a proxy for the process. We haven't gotten to test it yet but it seems like setting --proxy-server or --proxy-pac-url in the AdditionalBrowserArgument when creating the CoreWebView2EnvironmentOptions should work.
WebView2 _webView2 = new WebView2(); CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions(); // Set a proxy pac for the browser // options.AdditionalBrowserArguments = "--proxy-pac-url=http://myproxy.com/my.pac"; // Set the proxy for the browser options.AdditionalBrowserArguments = "--proxy-server=\"foopy:99\""; // Create the environment manually CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, options); await _webView2 .EnsureCoreWebView2Async(env);
How to set the user name and password??
@alexchx we have a similar requirement for setting a proxy for the process. We haven't gotten to test it yet but it seems like setting --proxy-server or --proxy-pac-url in the AdditionalBrowserArgument when creating the CoreWebView2EnvironmentOptions should work.
WebView2 _webView2 = new WebView2(); CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions(); // Set a proxy pac for the browser // options.AdditionalBrowserArguments = "--proxy-pac-url=http://myproxy.com/my.pac"; // Set the proxy for the browser options.AdditionalBrowserArguments = "--proxy-server=\"foopy:99\""; // Create the environment manually CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, options); await _webView2 .EnsureCoreWebView2Async(env);
Looks like the argument --proxy-pac-url
won't work
We just checked in a fix for respecting the system proxy (removing the –winhttp-proxy-resolver command line arg). It should be available in Canary and Dev builds 91.0.823.0+. It will also be available in the next stable WebView2 Runtime (around mid-April).
I believe this should also make the other proxy related command-line args (--proxy-server, --proxy-pac-url, etc.) begin to work again. Can you give those a try again with the fixed builds?
I have the same issue, but I'm not using C/C++. I tried to create the
CoreWebView2EnvironmentOptions
, as a COM-like, but doesn't work.The alternative is to set the
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
environment variable. Of course, you can set the variable to just your own application.In golang, which I'm using:
os.Setenv("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", fmt.Sprintf(`--proxy-server="%s"`, "192.0.0.1:7777"))
Regardless of the language used, you can set the environment variable and, in this case, set the proxy.
Hello Inkeliz
Can You please explain your approach in more details , i try this code
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", ""--proxy-server=HTTPS://140.227.66.105:58888") Dim envvalue = Environment.GetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS") Me.WebView22.Source = New Uri("https://www.whatismyip.com/")
but it look like something wrong!!!!
@pop711 I don't understand too much about C#, however, that might work:
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--proxy-server=\"140.227.66.105:58888\"")
The name is WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
and the value is --proxy-server="140.227.66.105:58888"
. You must declare that before start the WebViewer!
Note: Using HTTPS://140.227.66.105:58888
(with HTTPS://
scheme) will apply the proxy exclusively for HTTPS
traffic, ignoring any other protocol. So, it will not work if you are connecting to HTTP or FTP (or anything else rather than HTTP). If you use 140.227.66.105:58888
(without HTTP://
) it will apply to all protocols (including HTTP, HTTPS and FTP). If you are using SOCKS5, you can try using socks5://
, but I never tested that.
Is there any solution?
Hey @skiddow - Which piece of this thread did you need a solution to?
Hey @skiddow - Which piece of this thread did you need a solution to?
Hi @champnic I want to change proxy of webView2 as @igotbass said. I mean when we'll have this feature available.... Just wanted to bump the topic.
Forgive me if I missed this, is there an event raised if a page crashes in the webview2, the webview prompts that something has gone wrong with page click to reload. Can this state be detected ?
Also, old webBrowser allowed you to set the proxy per application,
The Webview2 appears to not work with this method. My use case is a app with fiddlercore built into it. Mutiple instances of this application are run on a RDP environment where each app is running on a separate proxy port. It appears that the only way to get this to work now is to have fiddlercore assign the proxy as a system proxy, but that effects all web traffic, I have not tested if this is overall or per session in server OS. Anyhow is there going to be a way to per application proxy like the old webbrowser?
Anybody having issues with socks5://
?
It doesn't work in my machine.
Forgive me if I missed this, is there an event raised if a page crashes in the webview2, the webview prompts that something has gone wrong with page click to reload. Can this state be detected ?
Also, old webBrowser allowed you to set the proxy per application,
https://docs.microsoft.com/en-us/archive/blogs/jpsanders/how-to-set-the-proxy-for-the-webbrowser-control-in-net
The Webview2 appears to not work with this method. My use case is a app with fiddlercore built into it. Mutiple instances of this application are run on a RDP environment where each app is running on a separate proxy port. It appears that the only way to get this to work now is to have fiddlercore assign the proxy as a system proxy, but that effects all web traffic, I have not tested if this is overall or per session in server OS. Anyhow is there going to be a way to per application proxy like the old webbrowser?
AB#25508072