|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Posting login data with HttpWebRequestmake 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 Hello adwooley2,
Show quoteHide quote > Hello. Have been losing plenty of hair over problem whereby I can't It sounds like you are not persisting the principal 's token in the cookies > 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, for the subsequent request. I'm not sure I can help much, but just wanted to say I love your username ;) Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx Thanks Jim. Not sure where I'll go with this, but appreciate the
reply. Yes, nice name indeed. I live in Japan currently, and the pronunciation of my last name always trips up the Japanese. Rgds, adwooley2 Jim Wooley wrote: Show quoteHide quote > Hello 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, > > It sounds like you are not persisting the principal 's token in the cookies > for the subsequent request. I'm not sure I can help much, but just wanted > to say I love your username ;) > > Jim Wooley > http://devauthority.com/blogs/jwooley/default.aspx
how to get both old and new value for a changed text box
check username and password in database A question of design How to make stacktrace include linenumber for release compiles? REPLACE method: unwanted multiple-replacement Detect right-click in MDI container's client area? word length occurance in a text.. how to run the execuatable before windows shutting down Visual Studio Proffessional 2005 How to re-start application? |
|||||||||||||||||||||||