Trying to retrieve webpage after logging in
I'm trying to log into a page, and retrieve the HTML, which can only be retrieved once I log in. If I used the URL
Code:
http://www.mywebsite.com/login.php?username=myusername&password=mypassword
explicitly in the web browser, it works fine and I log in, but when I try to do it in the VB .NET code, it doesn't work. I provided the code below.
Code:
Private Sub btnSync_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSync.Click
Dim request As WebRequest = WebRequest.Create("http://www.mywebsite.com/login.php?username=myusername&password=mypassword")
Dim response As WebResponse = request.GetResponse()
Dim s As Stream = response.GetResponseStream()
Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
Dim doc As String = sr.ReadToEnd()
Debug.Print(doc)
End Sub
Any ideas why this isnt working?
Re: Trying to retrieve webpage after logging in
what result do you get?
Also what horribly insecure website passes the username and password across a query string?
Re: Trying to retrieve webpage after logging in
I just get the web page that says "Invalid Login, Please try again". Its basically just a rejection page that you would get if you typed in your username and password incorrectly.
Re: Trying to retrieve webpage after logging in