Murray Brown
asked on
ASP.net VB.net html post error
Hi. I am getting an error marked at the line marked 'XXXXX
"The server committed a protocol violation. Section=Response.Status.Li ne"
I'm not sure what this means
Private Shared Sub start_post()
Try
'Our postvars
Dim buffer As Byte() = Encoding.ASCII.GetBytes("t est=postva r&test2=an other")
'Initialization, we use localhost, change if applicable
Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Crea te("http://127.0.0.1/test.php"), HttpWebRequest)
'Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST"
'We use form contentType, for the postvars.
WebReq.ContentType = "application/x-www-form-ur lencoded"
'The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length
'We open a stream for writing the postvars
Dim PostData As Stream = WebReq.GetRequestStream()
'Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length)
PostData.Close()
'Get the response handle, we have no true response yet!
Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetRespo nse(), HttpWebResponse) 'XXXX
'Let's show some information about the response
Console.WriteLine(WebResp. StatusCode )
Console.WriteLine(WebResp. Server)
'Now, we read the response (the string), and output it.
Dim Answer As Stream = WebResp.GetResponseStream( )
Dim _Answer As New StreamReader(Answer)
Console.WriteLine(_Answer. ReadToEnd( ))
'Congratulations, you just requested your first POST page, you
'can now start logging into most login forms, with your application
'Or other examples.
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
"The server committed a protocol violation. Section=Response.Status.Li
I'm not sure what this means
Private Shared Sub start_post()
Try
'Our postvars
Dim buffer As Byte() = Encoding.ASCII.GetBytes("t
'Initialization, we use localhost, change if applicable
Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Crea
'Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST"
'We use form contentType, for the postvars.
WebReq.ContentType = "application/x-www-form-ur
'The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length
'We open a stream for writing the postvars
Dim PostData As Stream = WebReq.GetRequestStream()
'Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length)
PostData.Close()
'Get the response handle, we have no true response yet!
Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetRespo
'Let's show some information about the response
Console.WriteLine(WebResp.
Console.WriteLine(WebResp.
'Now, we read the response (the string), and output it.
Dim Answer As Stream = WebResp.GetResponseStream(
Dim _Answer As New StreamReader(Answer)
Console.WriteLine(_Answer.
'Congratulations, you just requested your first POST page, you
'can now start logging into most login forms, with your application
'Or other examples.
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER