Question

Okay so I was going to post this on the last 3 errors I got, but I fixed those all(thankfully). I no longer get any kind of cookie blocked message, however now I get a Error logging in whether I'm putting in the correct password or an invalid one. I think its either A. a cookie storage error. B. or a problem with redirection.

Imports System.Text
Imports System.Net
Imports System.IO

Public Class Form1

Dim logincookie As CookieContainer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)         Handles Button1.Click
    Dim postData As String = "log=" & TextBox1.Text & "&pwd=" & TextBox2.Text & "wp-  submit=Log+In&redirect_to=""http://csvlife.com/wp-admin/" & "&wordpress_test_cookie=1"
    Dim tempcookies As New CookieContainer()
    Dim encoding As New UTF8Encoding
    Dim byteData As Byte() = encoding.GetBytes(postData)
    Dim postreq As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://csvlife.com/wp-login.php"), HttpWebRequest)
    postreq.Method = "POST"
    postreq.KeepAlive = True
    postreq.AllowAutoRedirect = True
    postreq.CookieContainer = tempcookies
    postreq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6pre) Gecko/20100903 Firefox/4.0b6pre"
    postreq.ContentType = "application/x-www-form-urlencoded"
    postreq.Referer = "http://csvlife.com/wp-login.php"
    postreq.ContentLength = byteData.Length
    Dim postreqstream As Stream = postreq.GetRequestStream()
    postreqstream.Write(byteData, 0, byteData.Length)
    postreqstream.Close()
    Dim postresponse As HttpWebResponse
    postresponse = DirectCast(postreq.GetResponse, HttpWebResponse)
    tempcookies.Add(postresponse.Cookies)
    logincookie = tempcookies
    Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
    Dim thepage As String = postreqreader.ReadToEnd
    If thepage.Contains("ERROR") Then
        MsgBox("Error logging in!")
    Else
        MsgBox("Lets Start Blogging!")
    End If
End Sub
End Class



I have my fiddler open and I've logged into the page and noticed that when I login regularly from by regular browser fiddler will show this:

enter image description here

then the results come in and it looks like this:

enter image description here

Clarification: The pictures above is what the web traffic info looks like when I login from any basic browser on my computer

Here is what it looks like what I login from the program: enter image description here

Always an error. enter image description here

And the request number is just 200 no 302 before or after.

However when I try through my program the req number always remains 200 which is post. Its like it never gets to redirect and I don't know why. Notes: This is my website and this not for any kind of malware or whatever. Its just for blog automation. If there was anything else I could find on this matter I would. At this point I have no other option. Thank you kindly for your help and consideration.

Was it helpful?

Solution

In line 9:

Dim postData As String = "log=" & TextBox1.Text & "&pwd=" & TextBox2.Text & "wp- submit=Log+In&redirect_to=""http://csvlife.com/wp-admin/" & "&wordpress_test_cookie=1"

The parameters to be sent with the post need to be separated with an ampersand, as written the password parameter has "wp- submit=Log+In&redirect_to=http://csvlife.com/wp-admin/" appended to it.

Assuming wp is a parameter: Dim postData As String = "log=" & TextBox1.Text & "&pwd=" & TextBox2.Text & "&wp- submit=Log+In&redirect_to=""http://csvlife.com/wp-admin/" & "&wordpress_test_cookie=1"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top