vb.net 2008 and web browser 2.0 controls with custom headers RRS feed

  • Question

  • I'm trying to develope a small browser app to talk to my website.
    The website is expecting a specific variable inside of the header to be sent from the application.

    Now I was able to do this with axwebbrowser controls but decided to switch over to the new 2.0 controls only to find that this has become a rather difficult task.

    I navigate to my site and then fire up the webbrowser1.navigating event so that I can append to the header my custom data which works fine and great but when I get to the site's login page as it's a vbulletin site I go and enter my username and password then click submit to only find it returning me back to the login screen again. It's like it's not submitting the data back to the forms.

    Basically I need the headers constantly updated with my custom data so that the web server doesn't deny the client access.

    How can I go about doing this please ?
    Tuesday, September 16, 2008 12:11 AM


  • Take a look at the following code snippet to see whether it satisfies your requirement.

    Public Class Form1 
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click 
            Dim vPost As Object 
            Dim vHeaders As Object 
            Dim cParamFlavor As String 
            Dim cParamName As String 
            Dim cPostData As String 
            Dim cSeparator As String 
            cParamFlavor = "Flavor=" 
            cSeparator = "&" 
            cParamName = "FName=" 
            cPostData = cParamName & "  test" 
            vHeaders = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13) 
            vPost = System.Text.ASCIIEncoding.ASCII.GetBytes(cPostData) 
            WebBrowser1.Navigate("http://localhost/Riquel/WebSite1/WebForm1.aspx"Nothing, vPost, vHeaders) 
        End Sub 
    End Class 

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, September 23, 2008 2:21 AM