I am having small problem geeting HttpStatusCode from response. Problem is when file exists I am getting response and can read read status, but when file doesn't exists I don't see any status, even if I asked to show me status string. Here is my code:
Dim urls As New List(Of String)
urls.Add("http://www.domain.com/test.php")
urls.Add("http://www.domain.com/test2.php")
urls.Add("http://www.domain.com/index.php")
For Each Url As String In urls
Dim response As HttpWebResponse = Nothing
Try
Dim request As HttpWebRequest = Net.HttpWebRequest.Create(Url)
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
request.Method = "GET"
response = request.GetResponse()
Catch webex As WebException
End Try
If response.StatusCode = HttpStatusCode.OK = True Then
MsgBox("File Url is correct: " & response.StatusCode.ToString)
ElseIf response.StatusCode = HttpStatusCode.NotFound = True Then
MsgBox("File Url is incorrect: " & Url)
Else
MsgBox(response.StatusCode.ToString)
End If
Next