Hi
I have the code below that I am using to login to my remote webpage.
The problem is that it seems to not post the data. I have heard that
ViewState can be a problem and that it may be necessary to retrieve the
ViewState field and Post it with the data, i have attempted test this by
copying the viewstate text out of the source and into the start of the
variable strPostData - as you can see commented out.
I am unsure why I do not get forwarded from the adminlogin.aspx page after
posting the data, could this be the viewstate or another issue?
Any advice would be much appreciated.
Thanks
B
Dim strURL As String
Dim strPostData As String
Dim byteResponse() As Byte
Dim i As Integer
Dim strViewState As String
strURL = strHttpLocation & "adminlogin.aspx"
strPostData =
"UsernameTextBox=username&PasswordTextBox=1234&Log inButton=Login"
'strPostData =
"__VIEWSTATE=dDwtNDU0NDA4NTk3Ozs+hQAoe3316Ljm9Gtmh xCl3GsRZjw=&UsernameTextBox=username&PasswordTextB ox=1234&LoginButton=Login"
'login
gobjWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")
byteResponse = gobjWebClient.UploadData(strURL, "POST",
System.Text.Encoding.ASCII.GetBytes(strPostData))
TextBox1.Text = System.Text.Encoding.ASCII.GetString(byteResponse)