help with Browsing using HttpWebrequest

pigalot

New member
Joined
Jul 27, 2007
Messages
1
Programming Experience
3-5
ok basicly im trying to browse a site using HttpWebrequest the site requires a login, i can get it to login using a post and it auto redirects me to the accounts page thats cool. now i want to browse to another page but it always sends me back to the login page again.

i am managing the cookies and im using a sniffer to look at the http headers the cookies are being sent but the main GET command thing gets changed to login.aspx.

is this something to do with veiwstate or something?

VB.NET:
Private Function Login(ByVal email As String, ByVal pass As String, ByVal gotopage As String) As IO.Stream
        Dim WebResponse As Net.HttpWebResponse
        MsgBox(loginURL & gotopage & "")
        Dim URL As String
        URL = loginURL & gotopage & ""
        request = CreateRequest(URL)
        request.ContentType = "application/x-www-form-urlencoded"
        request.Method = "POST"
        request.Referer = "login.aspx?href=" & gotopage & ""
        request.CookieContainer = New Net.CookieContainer()
        request.CookieContainer = cookies

        PostData = "email=" & email & "&pass=" & pass & "&post_back=true"
        request.ContentLength = PostData.Length

        Dim RequestWriter As New IO.StreamWriter(request.GetRequestStream())
        RequestWriter.Write(PostData)
        RequestWriter.Close()

        WebResponse = request.GetResponse()

        cookies.Add(WebResponse.Cookies)
        CookieUpdate()

        If cblogevents.Checked = True Then
            lstEvents.Items.Add("Loged in")
        End If

        Return WebResponse.GetResponseStream()

    End Function

this is my login post function gotopage is a test its ment to auto redirect to the page that is there but the page gets removed when i look in the sniffer.

VB.NET:
Private Sub test()
        Dim WebResponse As Net.HttpWebResponse
        request = CreateRequest(URL)
        request.CookieContainer = New Net.CookieContainer()
        request.CookieContainer = cookies
        request.Referer = URL
        WebResponse = request.GetResponse()

        cookies.Add(WebResponse.Cookies)
        CookieUpdate()

        txtSource.Text = Responseint(WebResponse.GetResponseStream)
    End Sub

VB.NET:
 Private Sub CookieUpdate()
        lstCookies.Items.Clear()
        Dim col As New Net.CookieCollection
        col = cookies.GetCookies(request.RequestUri)
        Dim cook As Net.Cookie
        For Each cook In col
            lstCookies.Items.Add(cook.Name & ", " & cook.Value)
        Next cook
        If lstCookies.Items.Count > 0 Then
            btnCCook.Enabled = True
        Else
            btnCCook.Enabled = False
        End If
    End Sub

anyone have any ideas?
iv searched everywere and tryed everything i can think of please help.
 
Back
Top