1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem Posting Data

Discussion in 'Visual Basic .NET' started by soulchief, Jun 30, 2009.

  1. soulchief

    soulchief Junior Member

    Joined:
    Oct 17, 2007
    Messages:
    117
    Likes Received:
    55
    Location:
    Canada
    Im trying to post data from a VB.NET application to a web form, but its not passing the fields (it is doing a posting request)

    Not all the code, just the code applicable to the problem.

    Code:
        Public Client As New System.Net.WebClient
        Public Function HTTPRequest(ByVal URL As String, ByVal postString As String, Optional ByVal Method As String = "POST") As String
            Dim serverResponse() As Byte
            Dim postBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(postString)
            Try
                serverResponse = Me.Client.UploadData(URL, Method, postBytes)
                ' Gets data from server!
            Catch ex As Exception
    
                MsgBox(ex.Message, MsgBoxStyle.Critical, ex.Source & " Error")
                Exit Function
            End Try
            Dim responseHTML As String = (System.Text.Encoding.ASCII.GetString(serverResponse))
            ' Turns server response(in bytes) into a string(HTML)
            Return responseHTML
        End Function
    
    
    
    'Execute function code
    
    Dim postStr As String = "type=100"
    Dim submiturl As String = "http://127.0.0.1/posting.php"
            response = HTTPRequest(submiturl, postStr)
    
    Any ideas?
     
  2. RandR

    RandR Registered Member

    Joined:
    May 18, 2009
    Messages:
    75
    Likes Received:
    25
    Home Page:
    What type of data is it? Do you have an example packet for the data POSTed?
    It doesn't look like you are setting up headers for the post request either. You'll need to do that.
     
    • Thanks Thanks x 1
  3. soulchief

    soulchief Junior Member

    Joined:
    Oct 17, 2007
    Messages:
    117
    Likes Received:
    55
    Location:
    Canada
    Got it to post data to a test page, but im trying to create an account creator and forum poster but I cant figure out what headers should be. Checked the headers being sent out and tried them, but no success.

    My Current header that is set up is:
    Code:
    web_post.Headers.Add("Content-Type", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
    
     
  4. soulchief

    soulchief Junior Member

    Joined:
    Oct 17, 2007
    Messages:
    117
    Likes Received:
    55
    Location:
    Canada
    nevermind, rewrote some of the code and its the forum posting is working now. Just gotta work on the account creator... doesnt like the captcha i provide it :/
     
  5. heiska

    heiska Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    138
    Likes Received:
    169
    I made an account creator for FaceBook in Java (which ended up failing due to flaw in POST implementation of jdic.browser). If you need to parse the correct values (captcha_session etc) for CAPTCHAs, I don't mind posting my regexes. Or if you figure out an easier to way to get the CAPTCHAs passed to decaptcher, you could let me know :p