Click here to Skip to main content
15,663,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim urlexist As Integer = 0
     Dim urlDoesNotExist As Integer = 0
     For Each line In TextBox1.Text.Split(Environment.NewLine)
         Dim url As New System.Uri(line)
         Dim req As System.Net.WebRequest
         req = System.Net.WebRequest.Create(url)
         Dim resp As System.Net.WebResponse
             resp = req.GetResponse()
             req = Nothing
             urlexist = urlexist + 1
             'MsgBox("Website Found!")
         Catch ex As Exception
             req = Nothing
             urlDoesNotExist = urlDoesNotExist + 1
             '   MsgBox("Website not found. Check the url and internet connection")
             Button1.Text = urlDoesNotExist + 1
         End Try
     MsgBox("exist is ", urlexist)
     MsgBox("non-exist is ", urlDoesNotExist)

What I have tried:

this loop stops after 2 why ? now i don't under stand what went wrong in this
Updated 27-Feb-17 19:55pm
Graeme_Grant 28-Feb-17 0:36am    
stops how?
Member 10974007 28-Feb-17 0:39am    
hangs after 8
Graeme_Grant 28-Feb-17 1:17am    
That's like saying my car won't start. Hangs how?
F-ES Sitecore 28-Feb-17 4:06am    
Make sure your request and response objects are both being disposed, the underlying network layer might be preventing you from having more that two connections to the same domain on the same port at the same time and that can happen in your code if you're not disposing your objects (setting to Nothing in a catch is not disposing)

1 solution

This should do the trick:
Private Function CheckUrl(uri As Uri) As Boolean
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create(uri), HttpWebRequest)
    request.Method = WebRequestMethods.Http.Head
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    Return response.StatusCode = HttpStatusCode.OK
End Function
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900