help checking if a page exists

hello again..

i'm making a program and i have a problem. I need to check if a webpage exists like "http://www.mydomain.com/page.html"
does anybody here knows how to help me?

thanks in advance
jack

Comments

  • : hello again..
    :
    : i'm making a program and i have a problem. I need to check if a
    : webpage exists like "http://www.mydomain.com/page.html"
    : does anybody here knows how to help me?
    :
    : thanks in advance
    : jack
    :
    If you working with VB.NET/ASP.NET you can use WebRequest object

    [code]
    Imports System.Net
    Public Class Form1

    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim request As WebRequest = WebRequest.Create("http://www.yahoo1.com")
    Dim response As HttpWebResponse
    Dim strMes As String
    [color=Green]' If required by the server, set the credentials.[/color]
    request.Credentials = CredentialCache.DefaultCredentials
    [color=Green]' Get the response.[/color]
    Try
    response = CType(request.GetResponse(), HttpWebResponse)
    Catch ex As Exception
    strMes = ex.Message
    End Try
    If strMes = "" Then
    Me.TextBox1.Text() = response.StatusDescription
    Else
    MsgBox("Page www.yahoo1.com not found " & strMes)
    End If
    End Sub


    End Class
    [/code]
    If page not exisist you will received Error: [color=Blue]"The remote server returned an error: (404) Not Found."[/color]

    I know you can do something like that using Java but not sure about JavaScript or VB 6.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion