WebBrowser.Navigate Method

Definition

Loads the document at the specified location into the WebBrowser control.

Overloads

Navigate(Uri, String, Byte[], String)

Loads the document at the location indicated by the specified Uri into the WebBrowser control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name.

Navigate(String, String, Byte[], String)

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name.

Navigate(Uri, Boolean)

Loads the document at the location indicated by the specified Uri into a new browser window or into the WebBrowser control.

Navigate(Uri, String)

Loads the document at the location indicated by the specified Uri into the WebBrowser control, replacing the contents of the Web page frame with the specified name.

Navigate(String, Boolean)

Loads the document at the specified Uniform Resource Locator (URL) into a new browser window or into the WebBrowser control.

Navigate(String, String)

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, replacing the contents of the Web page frame with the specified name.

Navigate(Uri)

Loads the document at the location indicated by the specified Uri into the WebBrowser control, replacing the previous document.

Navigate(String)

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, replacing the previous document.

Navigate(Uri, String, Byte[], String)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the location indicated by the specified Uri into the WebBrowser control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name.

C#
public void Navigate(Uri url, string targetFrameName, byte[] postData, string additionalHeaders);
C#
public void Navigate(Uri? url, string? targetFrameName, byte[]? postData, string? additionalHeaders);

Parameters

url
Uri

A Uri representing the URL of the document to load.

targetFrameName
String

The name of the frame in which to load the document.

postData
Byte[]

HTTP POST data such as form data.

additionalHeaders
String

HTTP headers to add to the default headers.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

The url parameter value does not represent an absolute URI. For more information, see IsAbsoluteUri.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window.

Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(String, String, Byte[], String)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name.

C#
public void Navigate(string urlString, string targetFrameName, byte[] postData, string additionalHeaders);
C#
public void Navigate(string urlString, string? targetFrameName, byte[]? postData, string? additionalHeaders);

Parameters

urlString
String

The URL of the document to load.

targetFrameName
String

The name of the frame in which to load the document.

postData
Byte[]

HTTP POST data such as form data.

additionalHeaders
String

HTTP headers to add to the default headers.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window.

Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(Uri, Boolean)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the location indicated by the specified Uri into a new browser window or into the WebBrowser control.

C#
public void Navigate(Uri url, bool newWindow);
C#
public void Navigate(Uri? url, bool newWindow);

Parameters

url
Uri

A Uri representing the URL of the document to load.

newWindow
Boolean

true to load the document into a new browser window; false to load the document into the WebBrowser control.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

The url parameter value does not represent an absolute URI. For more information, see IsAbsoluteUri.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a newWindow parameter value of false, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a newWindow parameter value of true, the WebBrowser control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the NewWindow event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the Refresh button.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(Uri, String)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the location indicated by the specified Uri into the WebBrowser control, replacing the contents of the Web page frame with the specified name.

C#
public void Navigate(Uri url, string targetFrameName);
C#
public void Navigate(Uri? url, string? targetFrameName);

Parameters

url
Uri

A Uri representing the URL of the document to load.

targetFrameName
String

The name of the frame in which to load the document.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

The url parameter value does not represent an absolute URI. For more information, see IsAbsoluteUri.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window.

Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(String, Boolean)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the specified Uniform Resource Locator (URL) into a new browser window or into the WebBrowser control.

C#
public void Navigate(string urlString, bool newWindow);

Parameters

urlString
String

The URL of the document to load.

newWindow
Boolean

true to load the document into a new browser window; false to load the document into the WebBrowser control.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a newWindow parameter value of false, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a newWindow parameter value of true, the WebBrowser control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the NewWindow event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the Refresh button.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(String, String)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, replacing the contents of the Web page frame with the specified name.

C#
public void Navigate(string urlString, string targetFrameName);
C#
public void Navigate(string urlString, string? targetFrameName);

Parameters

urlString
String

The URL of the document to load.

targetFrameName
String

The name of the frame in which to load the document.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window.

Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(Uri)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the location indicated by the specified Uri into the WebBrowser control, replacing the previous document.

C#
public void Navigate(Uri url);
C#
public void Navigate(Uri? url);

Parameters

url
Uri

A Uri representing the URL of the document to load.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

The url parameter value does not represent an absolute URI. For more information, see IsAbsoluteUri.

Examples

The following code example demonstrates how to use the Navigate method to implement an address bar for the WebBrowser control. This example requires that your form contains a WebBrowser control called webBrowser1, a TextBox control called TextBoxAddress, and a Button control called ButtonGo. When you type a URL into the text box and press ENTER or click the Go button, the WebBrowser control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL.

For the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application.

C#
// Navigates to the URL in the address box when 
// the ENTER key is pressed while the ToolStripTextBox has focus.
private void toolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        Navigate(toolStripTextBox1.Text);
    }
}

// Navigates to the URL in the address box when 
// the Go button is clicked.
private void goButton_Click(object sender, EventArgs e)
{
    Navigate(toolStripTextBox1.Text);
}

// Navigates to the given URL if it is valid.
private void Navigate(String address)
{
    if (String.IsNullOrEmpty(address)) return;
    if (address.Equals("about:blank")) return;
    if (!address.StartsWith("http://") &&
        !address.StartsWith("https://"))
    {
        address = "http://" + address;
    }
    try
    {
        webBrowser1.Navigate(new Uri(address));
    }
    catch (System.UriFormatException)
    {
        return;
    }
}

// Updates the URL in TextBoxAddress upon navigation.
private void webBrowser1_Navigated(object sender,
    WebBrowserNavigatedEventArgs e)
{
    toolStripTextBox1.Text = webBrowser1.Url.ToString();
}

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control navigates to the specified URI and adds it to the end of the history list. Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

You can use the Navigate method to implement an address bar similar to the one in Internet Explorer.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Navigate(String)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Loads the document at the specified Uniform Resource Locator (URL) into the WebBrowser control, replacing the previous document.

C#
public void Navigate(string urlString);

Parameters

urlString
String

The URL of the document to load.

Exceptions

This WebBrowser instance is no longer valid.

A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.

Remarks

The WebBrowser control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the WebBrowser control navigates to the specified URI and adds it to the end of the history list. Use the GoBack method to return the control to a previous page in the navigation history. Use the GoForward method to return to a later page in the navigation history after navigating backward.

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the Refresh method to force the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version.

You can use the Navigate method to implement an address bar similar to the one in Internet Explorer.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10