简体   繁体   中英

Proxy settings for .NET WebBrowser

I have looked everywhere for an answer and all I found was confusing-incomplete bits.

The best way I found was to modify the registry like so:

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);

This works, but I need to also set the username and the password for the proxy.

I found that you can use the WebProxy class as this takes the credentials, but it doesn't work with WebBrowser.

So the other alternative would be to create an application-wide proxy where all http requests are routed thru it.

Anyone has any help on this?

I reccomend you use an HttpListener and a HttpWebRequest . For more information look here .

The WebBrowser control is exactly the same as Internet Explorer. They use the same proxy settings. Look up the WinINET API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM