I am writing a fairly simple web site monitoring app. It uses a timer to call a class that requests a web page and measures the response. Problem is that the third time the class is called the app hangs. looking at the locals box I see that the properties of the httpURL object are 'Property Evaluation Failed' . Any clues as to why ythis is happening?

Imports System.Net
Imports System.Net.Sockets

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    End Sub

End Class
Public Class CheckSite

    Public Shared Sub Main(ByVal UrlMon As String)
        Dim httpReq As System.Net.HttpWebRequest
        Dim httpResp As System.Net.HttpWebResponse
        Dim ResponseTime As Integer
        Dim StartTime As Integer = System.Environment.TickCount
        Dim httpURL As New System.Uri(UrlMon)


            httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
            httpResp = CType(httpReq.GetResponse(), HttpWebResponse)

            Form1.RichTextBox1.AppendText("Response: " & httpReq.HaveResponse.ToString & vbCrLf)
            Form1.RichTextBox1.AppendText("ContentLength: " & httpResp.ContentLength.ToString & vbCrLf)
            Form1.RichTextBox1.AppendText("ContentType: " & httpResp.ContentType.ToString & vbCrLf)
            Form1.RichTextBox1.AppendText("StatusDescription: " & httpResp.StatusDescription.ToString & vbCrLf)

        Catch ex As Exception
            Form1.RichTextBox1.AppendText(ex.StackTrace.ToString() & vbCrLf)
        End Try
        ResponseTime = System.Environment.TickCount - StartTime
        Form1.RichTextBox1.AppendText("Response Time: " & ResponseTime.ToString & vbCrLf)
        Form1.RichTextBox1.AppendText("==================================" & vbCrLf & vbCrLf)

        httpReq = Nothing
        httpResp = Nothing
        httpURL = Nothing

    End Sub
End Class

I am having exactly the same issue, if you found a solution to this I would be very greatful to see it.

embed a browser in your app, hide it, and use that one to load a page. Then you can monitor if it loading ok etc. But to be honest it is not very reliable to try monitoring this yourself these days, if you are looking for uptime etc. As your own internet connection might also be a factor. Maybe have a look sometime at these online services that do the job for you perfectly with lots of stats, email and sms alerts. For example http://ismywebsiteonline.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.