Winhttp login site problem
Winhttp login site problem
Winhttp login site problem
Winhttp login site problem
Winhttp login site problem
Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem
Winhttp login site problem Winhttp login site problem
Winhttp login site problem
Go Back  Xtreme Visual Basic Talk > > > Winhttp login site problem


Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2012, 01:50 PM
mVisi0n mVisi0n is offline
Newcomer
 
Join Date: Apr 2012
Posts: 2
Default Winhttp login site problem


I'm trying to login this site "http://chomikuj.pl" via winhttp.

I spent 3 hours already ... can some1 help me?

How can I login to this site via winhttp?



my code;

Code:
    Dim logincookie As CookieContainer





    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim postData As String = "ReturnUrl=&Login=visionnn&Password=noidea&rememberLogin=false&topBar_LoginBtn=Zaloguj"

        Dim tempCookies As New CookieContainer

        Dim encoding As New UTF8Encoding

        Dim byteData As Byte() = encoding.GetBytes(postData)



        Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://chomikuj.pl/action/Login/TopBarLogin"), HttpWebRequest)

        postReq.Method = "POST"

        postReq.KeepAlive = True

        postReq.CookieContainer = tempCookies

        postReq.ContentType = "application/x-www-form-urlencoded"

        postReq.Referer = "http://chomikuj.pl/"

        postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"

        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



        RichTextBox1.Text = thepage

    End Sub
Reply With Quote
  #2  
Old 04-19-2012, 04:11 AM
mVisi0n mVisi0n is offline
Newcomer
 
Join Date: Apr 2012
Posts: 2
Default

Now I'm still getin 500 Internal Server Error :/
Can some1 help me?

Code:
Public Class Form1

 


    Dim logincookie As CookieContainer


 


 


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


 


        Dim postData As String = "FileId=0&Login=dzikig&Password=zniesmaczony&RememberMe=false&__RequestVerificationToken=9Jn3eiwHtsUB9diTXfOGFV1kyYGzudgoloshVY%2Fe3Tsa1JpVaU7JjYnCs61cbHIk96cC6TJsj8EP%2Bskw7BoK3n1JRGCj1ZKq1EV4epU7EGyv6qxg%2FGuEgvP%2B4dagLl7e6T1FYQ%3D%3D"


        Dim tempCookies As New CookieContainer


        Dim encoding As New UTF8Encoding


        Dim bytedata As Byte() = encoding.GetBytes(postData)


 


        Try


 


            Dim postreq As HttpWebRequest = DirectCast(WebRequest.Create("http://chomikuj.pl/action/Login/Login"), HttpWebRequest)


            postreq.ProtocolVersion = HttpVersion.Version10


            postreq.Method = "POST"


            postreq.KeepAlive = True


            postreq.CookieContainer = tempCookies


            postreq.ContentType = "application/x-www-form-urlencoded"


            postreq.Referer = "http://chomikuj.pl/lesiolo"


            postreq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0"


            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


            RichTextBox1.Text = thepage


 


 


 


        Catch e3 As WebException


 


            Console.WriteLine(e3.Message)


 


            If e3.Status = WebExceptionStatus.ProtocolError Then


                Console.WriteLine("Status Code : {0}", CType(e3.Response, HttpWebResponse).StatusCode)


                Console.WriteLine("Status Description : {0}", CType(e3.Response, HttpWebResponse).StatusDescription)


            End If


 


        Catch e2 As Exception


            Console.WriteLine(e2.Message)


        End Try


 


 


 


    End Sub
Reply With Quote
  #3  
Old 05-18-2012, 09:11 PM
lamy's Avatar
lamy lamy is offline
Junior Contributor
 
Join Date: Jan 2003
Location: under your bed
Posts: 347
Default

the problem is probably with your post data, im guessing __RequestVerificationToken, if you open that same website on different browsers each has its own value, possibly its tied to a session, creating a webrequest is like opening a browser

also, check the http headers, maybe youre missing something, it should be the same as what you are trying to send
__________________
slow down when you need to hurry, stop when you need to move on,
look back when you need to forget, or you might slip and leave sanity
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Winhttp login site problem
Winhttp login site problem
Winhttp login site problem Winhttp login site problem
Winhttp login site problem
Winhttp login site problem
Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem Winhttp login site problem
Winhttp login site problem
Winhttp login site problem
 
Winhttp login site problem
Winhttp login site problem
 
-->