WebProxy proxy = new WebProxy("http://webproxy");
proxy.Credentials = new NetworkCredential(username, password, domain);
GlobalProxySelection.Select = proxy;
WebClient wc = new WebClient();
byte[] data = wc.DownloadData("http://www.baidu.com");
string doc = Encoding.Default.GetString(data);
Console.WriteLine(doc);
proxy.Credentials = new NetworkCredential(username, password, domain);
GlobalProxySelection.Select = proxy;
WebClient wc = new WebClient();
byte[] data = wc.DownloadData("http://www.baidu.com");
string doc = Encoding.Default.GetString(data);
Console.WriteLine(doc);
WebRequest:
WebProxy proxy = new WebProxy("http://webproxy");
proxy.Credentials = new NetworkCredential(username, password, domain);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.baidu.com");
request.Proxy = proxy;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.Default);
Console.WriteLine(reader.ReadToEnd());
proxy.Credentials = new NetworkCredential(username, password, domain);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.baidu.com");
request.Proxy = proxy;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.Default);
Console.WriteLine(reader.ReadToEnd());