Internet History


  • I am building a web borwser and I noticed  that it sends the pages viewed to the Internet Explorer history. Is there any way to make it stop automtically doing this?
    I was alos wondering if there was a way to record internet history into a feature in my program...
    Tuesday, June 17, 2008 9:41 PM


  • Hi,

    Based on my understanding, you want to prevent the WebBrowser from adding the viewed URLs to the IE history.

    The WebBrowser control is just a wrapper of the Internet Explorer, so it's the default behaviour to record the viewd URLs in the IE history.  To workaround this, we can delete the viewed URL from the IE history when the navigating completed. 

    There's a good wrapper class on CodeProject.com which provides a DeleteHistoryEntry method for deleting a history entry from the IE history.

    The tiny wrapper class for URL history interface in C#

    We can take the following steps to use it:

    1. Download the sample from the link.
    2. In your project, right click on the project node, choose "Add Reference...".
    3. On the "Add Reference" dialog, select the "Browser" tab.
    4. Choose the "UrlHistoryLibrary.dll" file from the path "{TheSampleSavedPath}\UrlHistoryLibrary\bin\Debug".
    5. Import the UrlHistoryLibrary namespaces to your program.
    6. Navigate the WebBrowser to a specified page by calling the Navigate method.
    7. Handle the DocumentCompleted event of the WebBrowser control, add the two lines in it,

            Dim urlHistory As UrlHistoryWrapperClass = New UrlHistoryWrapperClass
            urlHistory.DeleteHistoryEntry(Me.WebBrowser1.Url.ToString, 0)

    8. Build and run the code, you'll find the WebBrowser is not longer keep the history.

    A full sample code:

    Imports System.Runtime.InteropServices.ComTypes

    Imports System.ComponentModel

    Imports UrlHistoryLibrary


    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _

        Handles MyBase.Load

            AddHandler WebBrowser1.DocumentCompleted, AddressOf Me.webBrowser1_DocumentCompleted

        End Sub


        Private Sub webBrowser1_DocumentCompleted(ByVal sender As Object, _

            ByVal e As WebBrowserDocumentCompletedEventArgs)

            Dim urlHistory As UrlHistoryWrapperClass = New UrlHistoryWrapperClass

            urlHistory.DeleteHistoryEntry(Me.WebBrowser1.Url.ToString, 0)

        End Sub


        End Sub

    End Class

    If you have anything unclear about this, please let me know.

    Zhi-Xin Ye

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, June 19, 2008 11:57 AM