F
Flashster
I'm a beginner so please be gentle.....
I want to (if its possible) post information to a web based form from my
windows form app and receive the resulting data from the web page.
The web forms code appears to be in javascript (not sure if that is
relevent).
I have tried, as a test, using the example code (see below), but the only
data I get back is the actual web page the data is on, without the resulting
data (as if the page is just reloading). Is this something I am doing wrong
(likely) or prehaps a restriction of the web site not allowing remote
submittions? The web form itself only requires a single field to be input.
The code I have tried:
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))
I want to (if its possible) post information to a web based form from my
windows form app and receive the resulting data from the web page.
The web forms code appears to be in javascript (not sure if that is
relevent).
I have tried, as a test, using the example code (see below), but the only
data I get back is the actual web page the data is on, without the resulting
data (as if the page is just reloading). Is this something I am doing wrong
(likely) or prehaps a restriction of the web site not allowing remote
submittions? The web form itself only requires a single field to be input.
The code I have tried:
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))