Hi

I'm not sure sure if this is the most appropriate forum for this question so if I'm in the wrong place, my apologies!

I have a text field in my application where a user can enter a URL. Once this URL has been validated, a linklabel is shown next to the textbox which has a hyperlink to the URL in the textbox.

My validation code looks like this at the moment:

Code:
Dim str_mess As String
        str_mess = ""

        If Not theURL.StartsWith("http://") And Not theURL.StartsWith("https://") And Not theURL.StartsWith("ftp://") Then
            theURL = "http://" & theURL
        End If

        Try
            Dim myReq As HttpWebRequest = WebRequest.Create(theURL)
            Dim myHttpWebResponse As HttpWebResponse = CType(myReq.GetResponse(), HttpWebResponse)
            myHttpWebResponse.Close()

        Catch e As WebException

            str_mess = e.Message
            MessageBox.Show("You have not entered a valid URL", "URL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        Finally
            If str_mess IsNot "" Then
                validateURL = False
            Else
                validateURL = True
            End If
        End Try
This works ok as far as it goes, but if I put in a URL without the www. prefix, it validates ok but won't navigate to the page when I click on the link.

My knowledge of internet protocols is sketchy to say the least and the stuff I've read so far has just confused me more! Some people seem to insist that any site will work without the www. whilst others are adamant that it's needed. I also know that there are other domains out there aside from http, https and ftp, but wouldn't know where to start with finding out what they are.

Does anyone know any way of getting some kind of definitive list so that I can validate all possibilities when it comes to URLs? Either that, or do you know a more elegant way of handling this validation? Thanks!