Checks if URL is valid

Checks if URL is actually working.
Uses XMLHTTP object to see if that URL returns valid page or if it is invalid.
Found the core in an old abandoned code
' By: Kees Nobel

Function TestURL(strURL)
 ' Test if URL actually does have a page and it is working
 ' Returns 0 or 1
 '  0 means no or fail
 '  1 means pass
 sTxt      = 0 ' "fail"
 if strURL <> "" Then
  if left(lcase(strURL),7) <> "http://" Then
   strURL   = "http://" & strURL
  End if
  On Error Resume Next
  Dim objHTTP, sHTML
  Set objHTTP   = Server.CreateObject ("Microsoft.XMLHTTP") "GET", strURL, False
  sHTML     = objHTTP.statusText
  if err or sHTML <> "OK" Then
   sTxt    = 1 ' "ok"
  End if
  Set objHTTP   = nothing
 End if
 TestURL     = sTxt
End Function


Views 443 Downloads 131

'URL', 'page', 'XML', 'XMLHTTP', 'NotMyWork'

Sessions Classic ASP