how to post a form data using WebBrowser.Navigate? (VB 2005)

i'm using the following code

Dim urlString As String = "abc.aspx"
Dim targetFrameName As String = Nothing
Dim ENCODER As System.Text.UTF8Encoding = New System.Text.UTF8Encoding
Dim PostData As Byte() = ENCODER.GetBytes("A=3")
Dim additionalHeaders As String = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)
WebBrowser1.Navigate(urlString, targetFrameName, PostData, additionalHeaders)

but it does not post any data. what am i doing wrong



Answer this question

how to post a form data using WebBrowser.Navigate? (VB 2005)

  • zu35926

    thanks, but that's not exactly what i'm looking for

    your example uses the webbrowser class that came with older frameworks. i'm trying to use the webbrowser control that comes with VS2005. There is no [Navigate2] method & [Navigate] has somewhat different signature.

    (http://msdn2.microsoft.com/en-us/library/ms161355.aspx)

    the sample that i posted above is my translation of the following C# code:

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=363793&SiteID=1

    i also tried different "postdata" encodings:

    Dim urlString As String = "abc.aspx"
    Dim targetFrameName As String = Nothing
    Dim additionalHeaders As String = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)
    Dim PostData As Byte()= System.Text.ASCIIEncoding.ASCII.GetBytes("A=3")
    WebBrowser1.Navigate(urlString, targetFrameName, PostData, additionalHeaders)

    and

    Dim urlString As String = "abc.aspx"
    Dim targetFrameName As String = Nothing
    Dim additionalHeaders As String = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)
    Dim ENCODER As System.Text.Encoding = System.Text.Encoding.UTF8
    Dim PostData As Byte() = ENCODER.GetBytes("A=3")
    WebBrowser1.Navigate(urlString, targetFrameName, PostData, additionalHeaders)

    but nothing seems to work


  • jepptje

    Here's a great KB article on how to do just that. It's in C# so if any of the code looks funny post it here and we'll translate it.

    http://support.microsoft.com/kb/313068/



  • how to post a form data using WebBrowser.Navigate? (VB 2005)