Hi,

I'm making a simple utility for browsing an intra-net site using VB.net webbrowser and for reasons outside my control, everything requires a passcode to be accessed. So, for example,

Index.html

is blocked by the company server but

Index.html?pass=123456

is allowed.

Is there a way to get the web browser to automatically add the "?pass=123456" bit to the end of every URL? Including images/ other content?

I'll take care of only using the "?pass=123456" on intra net sites, but what I need help with is getting it to Auto append.

I don't have VB on this computer, but I'm thinking of something like this:

Public Sub Webbrowser1_Navigate() Handles Webbrowser1.Navigate
'Preform intra-net check here
Webbrowser1.Location += "?pass=123456"
Webbrowser1.navigate()

Any thoughts?

See if this helps.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://google.com/")
    End Sub

    Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
        If WebBrowser1.Url.AbsoluteUri = "http://www.google.com/" Then
            WebBrowser1.Navigate(WebBrowser1.Url.AbsoluteUri & "?pass=123456")
        End If
        Me.Text = WebBrowser1.Url.AbsoluteUri
    End Sub
End Class

Doesn't it figure? I came up with that code a few minutes before you posted >_>

Thanks though, it works :D

Here's my code:

Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
        UpdateLabel.Text = e.Url.AbsoluteUri
        If e.Url.ToString.Substring(Len(e.Url.ToString) - 12) <> "?x=pt-sd.org" Then
            e.Cancel = True
            WebBrowser1.Navigate(e.Url.ToString & "?x=pt-sd.org", False)
        End If
        If WebBrowser1.CanGoBack Then BackBox.Enabled = True Else BackBox.Enabled = False
        If WebBrowser1.CanGoForward Then ForwardBox.Enabled = True Else ForwardBox.Enabled = False
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ComboBox1.Text = WebBrowser1.Document.Url.AbsoluteUri
        UpdatePanel.Visible = False
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.