A
adwooley2
Hello. Have been losing plenty of hair over problem whereby I can't
make it off the login page. Trying to pass login info to a login page
and then move on to another page within the site so that I can download
some data, but I keep getting the login page.
Any ideas on this?
Here's the code:
==================================================
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim httpRequest As HttpWebRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/"), HttpWebRequest)
Dim responseReader As StreamReader = New
StreamReader(httpRequest.GetResponse.GetResponseStream)
Dim responseData As String = responseReader.ReadToEnd
responseReader.Close()
Dim viewState As String = ExtractViewState(responseData)
Dim postData As String =
"iDirectLogin_userID=USERID&iDirectLogin_userPass=PASSWORD"
Dim cookies As CookieContainer = New CookieContainer
httpRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/"), HttpWebRequest)
httpRequest.Method = "POST"
httpRequest.KeepAlive = True
httpRequest.Timeout = 120 * 1000
httpRequest.ContentType = "application/x-www-form-urlencoded"
httpRequest.CookieContainer = cookies
Dim requestWriter As StreamWriter = New
StreamWriter(httpRequest.GetRequestStream)
requestWriter.Write(postData)
requestWriter.Close()
httpRequest.GetResponse.Close()
httpRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/search.aspx"),
HttpWebRequest)
httpRequest.CookieContainer = cookies
responseReader = New
StreamReader(httpRequest.GetResponse.GetResponseStream)
' and read the response
responseData = responseReader.ReadToEnd
responseReader.Close()
Response.Write(responseData)
End Sub
==================================
Here's what's in the form:
<input name="iDirectLogin:userID" type="text" id="iDirectLogin_userID"
style="width:100px;WIDTH: 100px" /></td>
<input name="iDirectLogin:userPass" type="password"
id="iDirectLogin_userPass" style="width:100px;WIDTH: 100px" /></td>
<input type="submit" name="iDirectLogin:btnLogIn" value="Log-In"
id="iDirectLogin_btnLogIn" class="button" style="width:80px;" />
Any help would be greatly appreciated.
Regards,
adwooley2
make it off the login page. Trying to pass login info to a login page
and then move on to another page within the site so that I can download
some data, but I keep getting the login page.
Any ideas on this?
Here's the code:
==================================================
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim httpRequest As HttpWebRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/"), HttpWebRequest)
Dim responseReader As StreamReader = New
StreamReader(httpRequest.GetResponse.GetResponseStream)
Dim responseData As String = responseReader.ReadToEnd
responseReader.Close()
Dim viewState As String = ExtractViewState(responseData)
Dim postData As String =
"iDirectLogin_userID=USERID&iDirectLogin_userPass=PASSWORD"
Dim cookies As CookieContainer = New CookieContainer
httpRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/"), HttpWebRequest)
httpRequest.Method = "POST"
httpRequest.KeepAlive = True
httpRequest.Timeout = 120 * 1000
httpRequest.ContentType = "application/x-www-form-urlencoded"
httpRequest.CookieContainer = cookies
Dim requestWriter As StreamWriter = New
StreamWriter(httpRequest.GetRequestStream)
requestWriter.Write(postData)
requestWriter.Close()
httpRequest.GetResponse.Close()
httpRequest =
CType(WebRequest.Create("http://www.idirect.co.jp/search.aspx"),
HttpWebRequest)
httpRequest.CookieContainer = cookies
responseReader = New
StreamReader(httpRequest.GetResponse.GetResponseStream)
' and read the response
responseData = responseReader.ReadToEnd
responseReader.Close()
Response.Write(responseData)
End Sub
==================================
Here's what's in the form:
<input name="iDirectLogin:userID" type="text" id="iDirectLogin_userID"
style="width:100px;WIDTH: 100px" /></td>
<input name="iDirectLogin:userPass" type="password"
id="iDirectLogin_userPass" style="width:100px;WIDTH: 100px" /></td>
<input type="submit" name="iDirectLogin:btnLogIn" value="Log-In"
id="iDirectLogin_btnLogIn" class="button" style="width:80px;" />
Any help would be greatly appreciated.
Regards,
adwooley2