Forum Moderators: open
I captured the HTTP packet when doing the POST manually and I used the same contents (other than viewstate) in POST.
Thanks
Pawan
Console.WriteLine("Got a login page")
Dim strPost As String = "textboxUserid=a&textboxPassword=b&buttonLogin=Log+in"
Dim myWriter As StreamWriter
Dim objRequest As HttpWebRequest = CType(WebRequest.Create(myResponse.ResponseUri), HttpWebRequest)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
Try
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write(strPost)
Catch e As Exception
Console.WriteLine(e.ToString)
Finally
myWriter.Close()
End Try
Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)
Dim newsr As New StreamReader(objResponse.GetResponseStream())
Dim respText As String = newsr.ReadToEnd()
newsr.Close()
Console.WriteLine(respText)