ILovephp123 ILovephp123 - 1 year ago 80
C# Question

WebProxy URI is not valid

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

Answer Source

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

proxy.Address = new Uri("http://96.44.147.138:6060");