request = WebRequest.Create("http://www.baidu.com") as HttpWebRequest;
request.Timeout = 5000;
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.11 Safari/537.36";
request.Accept = "*/*";
request.Referer = referurl;
request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");
request.Headers.Add("Accept-Charset", "GBK,utf-8;q=0.7,*;q=0.3");
request.Proxy = new WebProxy(_ip, int.Parse(_port));
response = (HttpWebResponse)request.GetResponse();
instream = response.GetResponseStream();
这里设置了 超时时间为5s 为什么 总是很久才超时呢? 坐等,多谢!
------解决方案--------------------
设置ReadWriteTimeout 属性试试
http://msdn.microsoft.com/library/b1w9c0s4.aspx