本文整理汇总了VB.NET中System.Net.HttpWebRequest.Headers属性的典型用法代码示例。如果您正苦于以下问题:VB.NET HttpWebRequest.Headers属性的具体用法?VB.NET HttpWebRequest.Headers怎么用?VB.NET HttpWebRequest.Headers使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了HttpWebRequest.Headers属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CType
' Create a new 'HttpWebRequest' Object to the mentioned URL.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest)
' Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine(ControlChars.Cr + "The HttpHeaders are " + ControlChars.Cr + ControlChars.Cr + ControlChars.Tab + "Name" + ControlChars.Tab + ControlChars.Tab + "Value" + ControlChars.Cr + "{0}", myHttpWebRequest.Headers)
' Print the HTML contents of the page to the console.
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim readBuff(256) As [Char]
Dim count As Integer = streamRead.Read(readBuff, 0, 256)
Console.WriteLine(ControlChars.Cr + "The HTML contents of page the are : " + ControlChars.Cr + ControlChars.Cr + " ")
While count > 0
Dim outputData As New [String](readBuff, 0, count)
Console.Write(outputData)
count = streamRead.Read(readBuff, 0, 256)
End While
' Close the Stream object.
streamResponse.Close()
streamRead.Close()
' Release the HttpWebResponse Resource.
myHttpWebResponse.Close()