I am using the following code to get a string from a server:
I would like to be able to get the status code that is returned by the server. ie. 200, 404, etc., but I can't figure out how to do it.Code:Dim handler = New HttpClientHandler With {.UseCookies = False} Dim http As New HttpClient(handler) Dim url1 As String = "SomeUrlString" http.DefaultRequestHeaders.Clear() http.DefaultRequestHeaders.Add("User-Agent", useragent) http.DefaultRequestHeaders.Add("Cookie", "mac=" & myMac) Try result = http.GetStringAsync(url1).Result Catch ex As Exception Console.WriteLine(ex.ToString) End Try
Can anyone help me out? Thanks...




Reply With Quote