日期:2014-05-18  浏览次数:20839 次

关于HttpWebRequest类的问题
现在使用HttpWebRequest,HttpWebResponse来验证网页是否存在。但是有些网站可以验证存在,有些网站却会超时,是为什么呢?
比如使用“http://topic.csdn.net/t/20041022/04/3479696.html”可以正常判断连接
但是使用“http://www.sooip.cn/zuixindaili/2012-05-10/2803.html”则WebException Raised. The following error occured :Timeout 

这两个网站都是可以连接的,为什么会出现超时的情况呢?

另外,我问的不是catch...try的问题哦~~我想知道为什么有些网页验证时会超时

------解决方案--------------------
没有超时啊。很快的

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.sooip.cn/zuixindaili/2012-05-10/2803.html");
request.Method = "HEAD";
request.Proxy = null;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
textBox1.Text = response.StatusDescription;