i'm a new in VB and i'm trying to make a program that gets and displays the HTTP response code of a website.
something like:
http response code of target website www.example.com : 200 OK
etc.
I Tried to code it myself but i couldn't , And i also tried to find online but i didn't found something that works.
i found this http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.statuscode(v=vs.110).aspx
i tried that and that didn't really helped me.
Anyone has a code that does that?
I'm a C# guy, so this might not be perfect, but I believe this should do it.
Public Shared Function GetResponse(uri As String) As HttpStatusCode
Dim req As HttpWebRequest = HttpWebRequest.CreateHttp(uri)
Dim resp As HttpWebResponse
Try
resp = DirectCast(req.GetResponse(), HttpWebResponse)
Catch ex As WebException
resp = DirectCast(ex.Response, HttpWebResponse)
End Try
Return resp.StatusCode
End Function