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
"Scott Ocamb" <so****@hotmail.com> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
I want to write a simple class that loads a requested url and reports
success or failure. I plan to use this to monitor web sites on the web.
I would like to implement the class in a windows form and a service.
Any help would be appreciated.
scott