5

I am using Microsoft Visual Studio 2010 C# .net 4.0

I have a webbrowser element. What i want to do is navigating via Webbrowser element with using proxy. How can i do that ? thank you.

2
  • +1. How do I subscribe to this topic? Commented Jun 28, 2011 at 20:26
  • 2
    @jp2code, that's what the star underneath the upvote/downvote arrows on the question are for. Click on it. Commented Jun 28, 2011 at 20:30

2 Answers 2

6

The browser control is just an instance of IE - it will use IE's proxy settings. You can set these by playing with registry keys if you must do it in code.

        string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
        string serverName = "";//your proxy server name;
        string port = ""; //your proxy port;
        string proxy = serverName + ":" + port;

        RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(key, true);
        RegKey.SetValue("ProxyServer", proxy);
        RegKey.SetValue("ProxyEnable", 1);

See this: http://social.msdn.microsoft.com/forums/en-US/winforms/thread/da510380-9571-4fcd-a05f-b165ced45017/

Update: Looks like this can be done for just the control and not the entire machine. See this code sample for setting the proxy for just a single process - http://blogs.msdn.com/b/jpsanders/archive/2011/04/26/how-to-set-the-proxy-for-the-webbrowser-control-in-net.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

This changes whole computer registry. I just want webbrowser element registery to be changed :( When i do this firefox etc everything uses that proxy.
1

See this link. You can easily set proxies for web requests but the WebBrowser class shares settings with iexplore.exe ... If you want, you can adjust the proxy settings by programmatically changing the IE registry values and then change them back (see brendan's answer).

How to set a proxy for Webbrowser Control without effecting the SYSTEM/IE proxy

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.