c# – WebProxy错误:需要代理验证
发布时间:2020-12-15 17:36:05 所属栏目:百科 来源:网络整理
导读:我使用以下代码来访问互联网上的html数据: WebProxy p = new WebProxy("localproxyIP:8080",true);p.Credentials = new NetworkCredential("domainuser","password");WebRequest.DefaultWebProxy = p;WebClient client = new WebClient();string download
我使用以下代码来访问互联网上的html数据:
WebProxy p = new WebProxy("localproxyIP:8080",true); p.Credentials = new NetworkCredential("domainuser","password"); WebRequest.DefaultWebProxy = p; WebClient client = new WebClient(); string downloadString = client.DownloadString("http://www.google.com"); 但是出现以下错误:“需要代理验证”. 解决方法
你必须设置WebClient.Proxy属性..
WebProxy p = new WebProxy("localproxyIP:8080","password"); WebRequest.DefaultWebProxy = p; WebClient client = new WebClient(); **client.Proxy = p;** string downloadString = client.DownloadString("http://www.google.com"); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |