首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于HttpWebRequest类的有关问题

2012-05-12 
关于HttpWebRequest类的问题现在使用HttpWebRequest,HttpWebResponse来验证网页是否存在。但是有些网站可以

关于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;

热点排行