Can you 'post' a web form from a stand-alone application.

  • Thread starter Thread starter KC
  • Start date Start date
K

KC

I want to submit an HTTP request to a site but the site needs to think it's
being POSTed from a form. How do I do that?
 
Imports System.Net

Module Module1

Sub Main()
Dim request As HttpWebRequest =
HttpWebRequest.Create("http://www.google.com")
Dim response As HttpWebResponse
Dim postData As String = "q" & ChrW(61) & "Sample Criteria"
Dim bytes As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(postData)
Dim output As IO.Stream

request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = postData.Length

output = request.GetRequestStream()
output.Write(bytes, 0, bytes.Length)
output.Close()

End Sub

End Module
 
Many thanks!

Ken

P.S. I'm still in the beat-your-head-against-the-wall-to-do-simple-things
stage.
 
Back
Top