3

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.

  1. An option to either a standard IP:Proxy
  2. An option with authentication.

I just can't seem to figure out how to connect it with the above code

1 Answer 1

3
    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!

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

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.