How to POST data

S

Sam Low

The following is the documentation on the WebClient Class in the VS .NET on POSTing data to a web page. My question is how do I enter the FORM parameters? Is it xxx=aaaaa? How to I separate multiple parameters? Thanks in advance.

[Visual Basic]

Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for example, http://www.contoso.com} : ")
uriString = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
' Apply ASCII Encoding to obtain the string as a byte array.
Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)
Console.WriteLine("Uploading to {0} ...", uriString)
' Upload the input string using the HTTP 1.0 POST method.
Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", byteArray)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :{0}", Encoding.ASCII.GetString(responseArray))
 
G

Girish bharadwaj

Pretty much x=y&r=t&l=blah.. so on..

--
Girish Bharadwaj
http://msmvps.com/gbvb
The following is the documentation on the WebClient Class in the VS .NET on
POSTing data to a web page. My question is how do I enter the FORM
parameters? Is it xxx=aaaaa? How to I separate multiple parameters?
Thanks in advance.

[Visual Basic]

Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for
example, http://www.contoso.com} : ")
uriString = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to
the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
' Apply ASCII Encoding to obtain the string as a byte array.
Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)
Console.WriteLine("Uploading to {0} ...", uriString)
' Upload the input string using the HTTP 1.0 POST method.
Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST",
byteArray)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :{0}",
Encoding.ASCII.GetString(responseArray))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top