本文整理汇总了VB.NET中System.Net.HttpWebRequest.ContentLength属性的典型用法代码示例。如果您正苦于以下问题:VB.NET HttpWebRequest.ContentLength属性的具体用法?VB.NET HttpWebRequest.ContentLength怎么用?VB.NET HttpWebRequest.ContentLength使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了HttpWebRequest.ContentLength属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: the
' Set the 'Method' property of the 'Webrequest' to 'POST'.
myHttpWebRequest.Method = "POST"
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the (http://www.contoso.com/codesnippets/next.asp) Uri :")
' Create a new string object to POST data to the Url.
Dim inputData As String = Console.ReadLine()
Dim postData As String = "firstone" + ChrW(61) + inputData
Dim encoding As New ASCIIEncoding()
Dim byte1 As Byte() = encoding.GetBytes(postData)
' Set the content type of the data being posted.
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
' Set the content length of the string being posted.
myHttpWebRequest.ContentLength = byte1.Length
Dim newStream As Stream = myHttpWebRequest.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)
Console.WriteLine("The value of 'ContentLength' property after sending the data is {0}", myHttpWebRequest.ContentLength)
newStream.Close()