General discussion
March 26, 2003 at 03:45 AM
jquinn

WebRequest Posting

by jquinn . Updated 23 years, 5 months ago

We have the following stitch of code behind a button click even of .NET windows application. It fails on the “Dim myResponse As WebResponse = myRequest.GetResponse” line with a 404. any ideas? Email for more info about what we are trying to do…jquinn@lsb.state.mi.us Thanks.

Dim myRequest As WebRequest = WebRequest.Create(“http://staging.mileg.org/testapp/form2.asp”)
Dim strPost As String = “textbox=simon”
MessageBox.Show(myRequest.RequestUri.ToString)myRequest.Method = “post”
myRequest.ContentLength = strPost.Length
myRequest.ContentType = “application/x-www-form-urlencoded”
Dim mystreamwriter As New StreamWriter(myRequest.GetRequestStream)
mystreamwriter.Write(strPost)
mystreamwriter.Close()
MessageBox.Show(myRequest.RequestUri.ToString)

‘ Return the response.
Dim myResponse As WebResponse = myRequest.GetResponse
Dim mystream As Stream = myResponse.GetResponseStream
Dim mystreamreader As New StreamReader(mystream)
Do Until mystreamreader.Peek = -1
TextBox1.Text += (mystreamreader.ReadLine.ToString())
Loop
mystreamreader.Close()
mystream.Close()

This discussion is locked

All Comments