Validating a URL address behind Cloudfare

Viewed 23

We have a very simple function to validate data entry for a URL in a WPF app.

Recently any website sitting behind Cloudfare is returning false. Is there a way to overcome this?

Public Function ValidURL(ByVal URL As String) As Boolean
    Dim sStream As IO.Stream

    Dim URLReq As System.Net.HttpWebRequest
    Dim URLRes As System.Net.HttpWebResponse
    Try
        URLReq = System.Net.WebRequest.Create(URL)
        URLRes = URLReq.GetResponse()
        sStream = URLRes.GetResponseStream()
        Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
        Return True
    Catch ex As Exception
        'Url not valid
        Return False
    End Try
End Function
0 Answers
Related