CWebView::Navigate Method  
 
BOOL Navigate(
  DWORD dwFlags,  
  LPCTSTR lpszUrl  
);
BOOL Navigate(
  LPCTSTR lpszUrl  
);

The Navigate method navigates to the specified URL or local file path.

Parameters

dwFlags
An unsigned integer which specifies additional options for how the navigation will be performed.
Value Description
WEBVIEW_NAVIGATE_DEFAULT Use the default navigation behavior. The specified URL or local file path is normalized and used without additional restrictions.
WEBVIEW_NAVIGATE_SAFE_URL Perform additional safety checks on the input before navigation. This will reject unsafe or malformed URLs, filter out potentially harmful schemes, and block traversal sequences (such as ../../) in local paths. This option is recommended when the URL or path is provided by external or untrusted input.
lpszUrl
A null-terminated string which specifies the URL or local file to navigate to. Any leading and trailing whitespace will be removed and the URL will be normalized to ensure that it specifies a valid location. If the URL only specifies a domain name (such as "example.com") the browser will default to using a secure connection. This parameter cannot be NULL.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The Navigate method accepts both standard web URLs such as https://www.example.com/ and local file paths which are automatically normalized and converted into file:// URLs. This allows an application to load either remote web content or content from the local filesystem.

When a local file path is specified, the method validates the path to ensure that it refers to a valid, absolute file system location and is not under restricted system folders (such as the Windows or Program Files directories). Relative paths are resolved against the current working directory, but it is recommended that applications provide absolute paths to avoid ambiguity in multithreaded or service-hosted environments.

File names and paths are normalized before navigation. Illegal or reserved device names (such as CON, AUX, or NUL) and paths containing invalid characters will be rejected. UNC paths and extended-length paths using the \\?\ prefix are not supported. If the path points to a valid file, it will be loaded into the WebView using the appropriate file:// URL form.

If the dwFlags parameter specifies WEBVIEW_NAVIGATE_SAFE_URL, the URL or path will undergo additional checks to ensure that it does not contain unsafe schemes, fragments, or traversal sequences. This is useful when the application accepts untrusted input that may be used for navigation.

Note that navigation to local files is supported, but applications should exercise caution when mixing remote and local content, as this may have cross-origin security implications. If your application needs to load dynamic HTML content, consider using SetDocumentText instead.

This method only supports navigation to standard web and local resources. Valid URL schemes are limited to http://, https://, file://, and about:blank. Other protocols or custom application schemes are not supported and will cause the method to fail. This includes the edge://settings/profile page or any other internal configuration settings for the Edge browser. If your application needs to handle such protocols, you should implement a custom handler to intercept those links and handle them externally.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also