Reputation: 378
This is the code I have right now
using (WebClient client = new WebClient())
{
Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}
Now, I would like to put in 2 options for a proxy.
I just can't seem to figure out how to connect it with the above code
Upvotes: 3
Views: 5837
Reputation: 378
using (WebClient client = new WebClient()) {
client.Proxy = new WebProxy("31.4.5.26", 8080); // proxy's host,port
client.Proxy.Credentials = new NetworkCredential("proxyuser", "proxypassword");
Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}
Works fine for me!
Upvotes: 3