How to add WebProxy to the ChromiumWebBrowser control

Andreas ss 726 Reputation points
2021-10-19T23:16:25.22+00:00

Hello!

I am using the ChromiumWebBrowser control. What I simply now wonder is how to add a proxy to this ChromiumWebBrowser. In the code below I am creating 2 instances of the ChromiumWebBrowser and put them in a List.

I then iterate this list and now wonder how to add a WebProxy to each instance (Each instance will get a random IP address from p.webshare.io)
When connecting with the host: "p.webshare.io" this, will generate a random IP address each time. So I don't know the actual IP address as it happens by that website. This is how I set up the WebProxy with webrequests normally.

How to do add this to the ChromiumWebBrowser ? (The code below is not complete but I hope the code explains what I am trying to do)

Thank you!

                ChromiumWebBrowser chromebrowser1 = new ChromiumWebBrowser("http://test.com"); //Instance 1
                ChromiumWebBrowser chromebrowser2 = new ChromiumWebBrowser("http://test.com"); //Instance 1
                List<ChromiumWebBrowser> chromebrowserLIST = new List<ChromiumWebBrowser>();
                chromebrowserLIST.Add(chromebrowser1); chromebrowserLIST.Add(chromebrowser2); //Add instances to List

                //Now iterate those browsers and put a proxy to each of them!
                for (int i = 0; i < chromebrowserLIST.Count; i++)
                {
                    //This is the webproxy I use. When connecting like this: "p.webshare.io" will generate a random IP address each time. So I don't know the actual IP address
                    //So this is the method I use with webrequests normally. How to do add this to the ChromiumWebBrowser ?
                    WebProxy myproxy = new WebProxy("p.webshare.io", 80);
                    myproxy.Credentials = new NetworkCredential("abcde-rotate", "somepasswordhere");

                    chromebrowserLIST[i] = myproxy //How to add the above "myproxy" to this instance of ChromiumWebBrowser ?
                }
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,236 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.