WebBrowser.Navigate Method (Uri, String, Byte(), String)

Updated: July 2008

Navigate asynchronously to the document at the specified Uri and specify the target frame to load the document's content into. Additional HTTP POST data and HTTP headers can be sent to the server as part of the navigation request.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

'Declaration
Public Sub Navigate ( _
	source As Uri, _
	targetFrameName As String, _
	postData As Byte(), _
	additionalHeaders As String _
)
'Usage
Dim instance As WebBrowser 
Dim source As Uri 
Dim targetFrameName As String 
Dim postData As Byte()
Dim additionalHeaders As String

instance.Navigate(source, targetFrameName, _
	postData, additionalHeaders)
You cannot use methods in XAML.

Parameters

source
Type: System.Uri

The Uri to navigate to.

targetFrameName
Type: System.String

The name of the frame to display the document's content in.

postData
Type: System.Byte()

HTTP POST data to send to the server when the source is requested.

additionalHeaders
Type: System.String

HTTP headers to send to the server when the source is requested.

ExceptionCondition
ObjectDisposedException

The WebBrowser instance is no longer valid.

InvalidOperationException

A reference to the underlying native WebBrowser could not be retrieved.

SecurityException

Navigation from an application that is running in partial trust:

  • To a Uri that is not located at the site of origin, or

  • targetFrameName name is not Nothing or empty.

The following example shows how to navigate to a document and open it in a new browser window by specifying the "about:blank" target.

    <StackPanel>
        <StackPanel Orientation="Horizontal">
            <TextBox x:Name="addressTextBox" Width="200" />
            <Button Click="goNavigateButton_Click">Go</Button>
        </StackPanel>
        <WebBrowser x:Name="myWebBrowser" />
    </StackPanel>
        private void goNavigateButton_Click(object sender, RoutedEventArgs e)
        {
            // Get URI to navigate to
            Uri uri = new Uri(this.addressTextBox.Text, UriKind.RelativeOrAbsolute);

            // Only absolute URIs can be navigated to
            if (!uri.IsAbsoluteUri)
            {
                MessageBox.Show("The Address URI must be absolute eg 'http://www.microsoft.com'");
                return;
            }

            // Navigate to the desired URL by calling the .Navigate method
            this.myWebBrowser.Navigate(uri, "_blank", null, null);
        }

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP2

Date

History

Reason

July 2008

Added topic for new class.

SP1 feature change.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft