You may be able to use the System.Net.WebClient to perform the task. But, if
you are running the code as a service make sure an account other than system
is specified or the service won't have access to resources off the machine.
HTH,
Jared
Shared Sub Main()
Console.WriteLine("Google: " &
CheckSite("
http://www.google.com").ToString)
Console.WriteLine("MSN: " & CheckSite("
http://www.msn.com").ToString)
Console.WriteLine("Bad URL: " &
CheckSite("
http://www.thisisabadurl.com").ToString)
Console.ReadLine()
End Sub
Shared Function CheckSite(ByVal URL As String) As Boolean
Dim wcSiteStatus As New System.Net.WebClient
Dim stream As System.IO.Stream = New System.IO.MemoryStream
Dim reader As System.IO.StreamReader
Try
With wcSiteStatus
stream = .OpenRead(URL)
reader = New System.IO.StreamReader(stream)
If reader.Peek > 0 Then
Return True
Else
Return False
End If
End With
Catch ex As Exception
Return False
Finally
If Not reader Is Nothing Then reader.Close()
wcSiteStatus.Dispose()
End Try
End Function