WebHeaderCollection.GetValues gets an array of header values stored in a header.
Imports System.IO
Imports System.Net
Imports System.Text
public class MainClass
Shared Sub Main()
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
myHttpWebRequest.Timeout = 1000
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebResponse.Headers
Dim i As Integer
For i = 0 To myWebHeaderCollection.Count - 1
Dim header As [String] = myWebHeaderCollection.GetKey(i)
Dim values As [String]() = myWebHeaderCollection.GetValues(header)
If values.Length > 0 Then
Console.WriteLine(header)
Dim j As Integer
For j = 0 To values.Length - 1
Console.WriteLine(ControlChars.Tab + "{0}", values(j))
Next j
End If
Next i
End Sub
End Class
Related examples in the same category