WebBrowser::Navigate Method (Uri^, String^, array<Byte>^, String^)
![]() |
---|
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience. |
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.
Assembly: PresentationFramework (in PresentationFramework.dll)
public: void Navigate( Uri^ source, String^ targetFrameName, array<unsigned char>^ postData, String^ additionalHeaders )
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:
array<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.
Exception | Condition |
---|---|
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:
|
Use the Navigate(String^, String^, array<Byte>^, String^) method to navigate to a URL that may include escape characters. Use the Navigate(Uri^, String^, array<Byte>^, String^) method to navigate to a Uri that does not include escape characters.
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); }
Available since 3.0