1

I got this from Load web browser with web response. and am wondering how I can use this code to use proxies that need a username and password to be able to work.

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");
webRequest.Proxy = new WebProxy(host, port);

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Stream receiveStream = response.GetResponseStream();

WebBrowser webBrowser = new WebBrowser();
webBrowser.DocumentStream = receiveStream;    
Community
  • 1
  • 1
user1455112
  • 173
  • 1
  • 2
  • 17

1 Answers1

3
var webProxy = new WebProxy(host,port);
webProxy.Credentials = new NetworkCredential("username", "password", "domain");
var webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");
webRequest.Proxy = webProxy;
Baz1nga
  • 15,485
  • 3
  • 35
  • 61