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
        Timer1.Start()
    End Sub

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

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        CheckSite.Main(TextBox1.Text)
        System.Windows.Forms.Application.DoEvents()
    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)

        Try


            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.Timer2.Stop()
        'MsgBox(Form1.Timer2.ToString())
        Form1.RichTextBox1.AppendText("==================================" & vbCrLf & vbCrLf)

        httpReq = Nothing
        httpResp = Nothing
        httpURL = Nothing

        System.Windows.Forms.Application.DoEvents()
    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

This article has been dead for over six months. Start a new discussion instead.