如何检测 WebRequest 由于 Web 代理错误而不是目标 Web 服务器错误而失败?
try
{
var request = (HttpWebRequest)WebRequest.Create("http://www.example.com");
request.Proxy = new WebProxy("localhost");
var response = request.GetResponse();
return response.GetResponseStream();
}
catch(WebException webex)
{
//Detect proxy failure
}