当前位置: 代码迷 >> Web前端 >> HttpWebResponse 远程服务器返回异常: (407) 需要代理身份验证
  详细解决方案

HttpWebResponse 远程服务器返回异常: (407) 需要代理身份验证

热度:167   发布时间:2012-10-21 09:00:07.0
HttpWebResponse 远程服务器返回错误: (407) 需要代理身份验证。

今天在公司 爬自己本地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;
        }


  相关解决方案