help checking if a page exists - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

  • lionblionb Posts: 1,688Member ✭✭
    : 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.