VB.NET如何检查网页是否存在 [英] VB.NET how to check if a webpage exists

查看:69
本文介绍了VB.NET如何检查网页是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查vb.net应用程序中是否存在网页?

Is it possible to check if a webpage exists or not in vb.net application ?

推荐答案

您可以通过请求有问题的网页并查看是否存在错误消息来找出答案.

You can find out by requesting the webpage in question and looking if there's an error message.

    Dim req As System.Net.WebRequest
    Dim res As System.Net.WebResponse

    req = System.Net.WebRequest.Create("http://www.google.com/werwerfsdfsdf")

    Try
        res = req.GetResponse()
    Catch e As WebException
        ' URL doesn't exists
    End Try

这篇关于VB.NET如何检查网页是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆