0

This is the code I currently have

using (WebClient client = new WebClient()) {
    WebProxy proxy = new WebProxy();
    proxy.Address = new Uri(96.44.147.138:6060);
    proxy.Credentials = new NetworkCredential(proxyUsername.Text, proxyPassword.Text);
    proxy.UseDefaultCredentials = false;
    proxy.BypassProxyOnLocal = false;
    Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}

The proxy needs credentials.

I get an error on line proxy.Address = new Uri(96.44.147.138:6060); saying

"The URI scheme is not valid."

Not sure what kind of value it's expecting

Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
Dgameman1
  • 378
  • 5
  • 24

2 Answers2

1

The Uri should consist of scheme host and optiona port. So you should use

proxy.Address = new Uri("http://96.44.147.138:6060");
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68
1

Must be like;

using (var client = new WebClient())
{
    var proxy = new WebProxy();

    proxy.Address = new Uri("http://96.44.147.138:6060");
    proxy.Credentials = new NetworkCredential(proxyUsername.Text, proxyPassword.Text);
    proxy.UseDefaultCredentials = false;
    proxy.BypassProxyOnLocal = false;

    Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}

Example edit: Setting a global HTTP proxy in C# and .NET client classes

Umut D.
  • 1,746
  • 23
  • 24