这是我目前的代码
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/"));
}代理需要凭证。
我在网上看到一个错误,proxy.Address = new Uri(96.44.147.138:6060);说
“URI方案无效。”
不知道它期待的是什么样的价值
发布于 2016-08-20 08:24:12
Uri应由方案、主机和选项端口组成。所以你应该用
proxy.Address = new Uri("http://96.44.147.138:6060");发布于 2016-08-20 08:24:38
一定是那样的;
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/"));
}示例编辑:在C#和.NET客户端类中设置全局HTTP代理
https://stackoverflow.com/questions/39052009
复制相似问题