今天在公司 爬自己本地iis是出现一个 错误提示“ 远程服务器返回错误: (407) 需要代理身份验证” ,现在把解决方案提出来
static bool GetRequest(string url)
{
WebProxy proxy = new WebProxy("10.16.8.52:80", false);
proxy.Credentials = new NetworkCredential("majiang", "****", "Vancl");
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
request.AllowAutoRedirect = false;
request.Proxy = proxy;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
response.Close();
return response.StatusCode == HttpStatusCode.OK;
}