我正在使用这段小代码来访问远程 Uri:
Uri uri = "http://www.myurl.com";
WebRequest wreq = WebRequest.Create(uri);
((HttpWebRequest)wreq).UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1";
wreq.Proxy = WebRequest.DefaultWebProxy;
这适用于所有“http”Uri。但是,当切换到以下类型的 Uri (https) 时,我收到请求身份验证的代理错误 407(异常日志表明凭据错误)。你知道我该如何处理吗?
Uri uri = "https://www.myurl.com";
WebRequest wreq = WebRequest.Create(uri);
((HttpWebRequest)wreq).UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1";
wreq.Proxy = WebRequest.DefaultWebProxy;
最好的祝福,
Al_th