关于HttpWebRequest的proxy属性
我想用HttpWebRequest的proxy去连接服务器,然后通过请求baidu,看看服务器有没有连上的
HttpWebRequest objHttpRequest;HttpWebResponse objResponse;WebProxy objProxy;objHttpRequest = (HttpWebRequest)WebRequest.Create("http://www.baidu.com"); //设定测试页面,用百度来测试objHttpRequest.Timeout = 3000; //设定超时时间string ip = "122.72.2.200";int port = 80;objProxy = new WebProxy(ips, ports); //创建proxyobjProxy.BypassProxyOnLocal = false;objHttpRequest.Proxy = objProxy; try { objResponse = (HttpWebResponse)objHttpRequest.GetResponse();//获取答复 } catch (Exception) {}