Microsoft.Web.WebView2.Core Mode for how the Bounds property is interpreted in relation to the RasterizationScale property. Bounds property represents raw pixels. Physical size of Webview is not impacted by RasterizationScale. Bounds property represents logical pixels and the RasterizationScale property is used to get the physical size of the WebView. Specifies the browser process exit type used in the `ICoreWebView2BrowserProcessExitedEventArgs` interface. Indicates that the browser process ended normally. Indicates that the browser process ended unexpectedly. A `ProcessFailed` event will also be sent to listening WebViews from the `ICoreWebView2Environment` associated to the failed process. Specifies the datatype for the `ICoreWebView2Profile2::ClearBrowsingData` method. Specifies file systems data. Specifies data stored by the IndexedDB DOM feature. Specifies data stored by the localStorage DOM API. Specifies data stored by the Web SQL database DOM API. Specifies data stored by the CacheStorage DOM API. Specifies DOM storage data, now and future. This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_FILE_SYSTEMS, COREWEBVIEW2_BROWSING_DATA_KINDS_INDEXED_DB, COREWEBVIEW2_BROWSING_DATA_KINDS_LOCAL_STORAGE, COREWEBVIEW2_BROWSING_DATA_KINDS_WEB_SQL, COREWEBVIEW2_BROWSING_DATA_KINDS_SERVICE_WORKERS, COREWEBVIEW2_BROWSING_DATA_KINDS_CACHE_STORAGE, and some other data kinds not listed yet to keep consistent with [DOM-accessible storage](https://www.w3.org/TR/clear-site-data/#storage). Specifies HTTP cookies data. Specifies all site data, now and future. This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_DOM_STORAGE and COREWEBVIEW2_BROWSING_DATA_KINDS_COOKIES. New site data types may be added to this data kind in the future. Specifies disk cache. Specifies download history data. Specifies general autofill form data. This excludes password information and includes information like: names, street and email addresses, phone numbers, and arbitrary input. This also includes payment data. Specifies password autosave data. Specifies browsing history data. Specifies settings data. Specifies profile data that should be wiped to make it look like a new profile. This does not delete account-scoped data like passwords but will remove access to account-scoped data by signing the user out. Specifies all profile data, now and future. New profile data types may be added to this data kind in the future. This browsing data kind is inclusive of COREWEBVIEW2_BROWSING_DATA_KINDS_ALL_SITE, COREWEBVIEW2_BROWSING_DATA_KINDS_DISK_CACHE, COREWEBVIEW2_BROWSING_DATA_KINDS_DOWNLOAD_HISTORY, COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL, COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE, COREWEBVIEW2_BROWSING_DATA_KINDS_BROWSING_HISTORY, and COREWEBVIEW2_BROWSING_DATA_KINDS_SETTINGS. Specifies service workers registered for an origin, and clear will result in termination and deregistration of them. Specifies the image format for the `ICoreWebView2::CapturePreview` method. Indicates that the PNG image format is used. Indicates the JPEG image format is used. The channel search kind determines the order that release channels are searched for during environment creation. The default behavior is to search for and use the most stable channel found on the device. The order from most to least stable is: WebView2 Runtime -> Beta -> Dev -> Canary. Switch the order to prefer the least stable channel in order to perform pre-release testing. See `COREWEBVIEW2_RELEASE_CHANNELS` for descriptions of channels. Search for a release channel from most to least stable: WebView2 Runtime -> Beta -> Dev -> Canary. This is the default behavior. Search for a release channel from least to most stable: Canary -> Dev -> Beta -> WebView2 Runtime. Specifies the client certificate kind. Specifies smart card certificate. Specifies PIN certificate. Specifies other certificate. Specifies the menu item kind for the `ICoreWebView2ContextMenuItem::get_Kind` method Specifies a command menu item kind. Specifies a check box menu item kind. `ContextMenuItem` objects of this kind will need the `IsChecked` property to determine current state of the check box. Specifies a radio button menu item kind. `ContextMenuItem` objects of this kind will need the `IsChecked` property to determine current state of the radio button. Specifies a separator menu item kind. `ContextMenuItem` objects of this kind are used to signal a visual separator with no functionality. Specifies a submenu menu item kind. `ContextMenuItem` objects of this kind will contain a `ContextMenuItemCollection` of its children `ContextMenuItem` objects. Indicates the kind of context for which the context menu was created for the `ICoreWebView2ContextMenuTarget::get_Kind` method. This enum will always represent the active element that caused the context menu request. If there is a selection with multiple images, audio and text, for example, the element that the end user right clicks on within this selection will be the option represented by this enum. Indicates that the context menu was created for the page without any additional content. Indicates that the context menu was created for an image element. Indicates that the context menu was created for selected text. Indicates that the context menu was created for an audio element. Indicates that the context menu was created for a video element. Kind of cookie SameSite status used in the ICoreWebView2Cookie interface. These fields match those as specified in https://developer.mozilla.org/docs/Web/HTTP/Cookies#. Learn more about SameSite cookies here: https://tools.ietf.org/html/draft-west-first-party-cookies-07 None SameSite type. No restrictions on cross-site requests. Lax SameSite type. The cookie will be sent with "same-site" requests, and with "cross-site" top level navigation. Strict SameSite type. The cookie will only be sent along with "same-site" requests. The default download dialog can be aligned to any of the WebView corners by setting the `DefaultDownloadDialogCornerAlignment` property. The default position is top-right corner. Top-left corner of the WebView. Top-right corner of the WebView. Bottom-left corner of the WebView. Bottom-right corner of the WebView. Reason why a download was interrupted. Generic file error. Access denied due to security restrictions. Disk full. User should free some space or choose a different location to store the file. Result file path with file name is too long. File is too large for file system. Microsoft Defender Smartscreen detected a virus in the file. File was in use, too many files opened, or out of memory. File blocked by local policy. Security check failed unexpectedly. Microsoft Defender SmartScreen could not scan this file. Seeking past the end of a file in opening a file, as part of resuming an interrupted download. The file did not exist or was not as large as expected. Partially downloaded file was truncated or deleted, and download will be restarted automatically. Partial file did not match the expected hash and was deleted. Download will be restarted automatically. Generic network error. User can retry the download manually. Network operation timed out. Network connection lost. User can retry the download manually. Server has gone down. User can retry the download manually. Network request invalid because original or redirected URI is invalid, has an unsupported scheme, or is disallowed by network policy. Generic server error. User can retry the download manually. Server does not support range requests. Server does not have the requested data. Server did not authorize access to resource. Server certificate problem. Server access forbidden. Unexpected server response. Responding server may not be intended server. User can retry the download manually. Server sent fewer bytes than the Content-Length header. Content-length header may be invalid or connection may have closed. Download is treated as complete unless there are [strong validators](https://tools.ietf.org/html/rfc7232#section-2) present to interrupt the download. Unexpected cross-origin redirect. User canceled the download. User shut down the WebView. Resuming downloads that were interrupted during shutdown is not yet supported. User paused the download. WebView crashed. State of the download operation. The download is in progress. The connection with the file host was broken. The `InterruptReason` property can be accessed from `ICoreWebView2DownloadOperation`. See `COREWEBVIEW2_DOWNLOAD_INTERRUPT_REASON` for descriptions of kinds of interrupt reasons. Host can check whether an interrupted download can be resumed with the `CanResume` property on the `ICoreWebView2DownloadOperation`. Once resumed, a download is in the `COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS` state. The download completed successfully. Specifies the image format to use for favicon. Indicates that the PNG image format is used. Indicates the JPEG image format is used. Kind of CoreWebView2FileSystemHandle as described in [FileSystemHandle.kind](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind). FileSystemHandle is for a file [FileSystemFileHandle](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle). FileSystemHandle is for a directory [FileSystemDirectoryHandle](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle). Allowed permissions of a CoreWebView2FileSystemHandle as described in [FileSystemHandle.requestPermission()](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission). Read-only permission for FileSystemHandle. Read and write permissions for FileSystemHandle. Indicates the frame type used in the `ICoreWebView2FrameInfo` interface. Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. Indicates that the frame is a primary main frame(webview). Indicates that the frame is an iframe. Indicates that the frame is an embed element. Indicates that the frame is an object element. Kind of cross origin resource access allowed for host resources during download. Note that other normal access checks like same origin DOM access check and [Content Security Policy](https://developer.mozilla.org/docs/Web/HTTP/CSP) still apply. The following table illustrates the host resource cross origin access according to access context and `CoreWebView2HostResourceAccessKind`. Cross Origin Access ContextDenyAllowDenyCorsFrom DOM like src of img, script or iframe elementDenyAllowAllowFrom Script like Fetch or XMLHttpRequestDenyAllowDeny All cross origin resource access is denied, including normal sub resource access as src of a script or image element. All cross origin resource access is allowed, including accesses that are subject to Cross-Origin Resource Sharing(CORS) check. The behavior is similar to a web site sends back http header Access-Control-Allow-Origin: *. Cross origin resource access is allowed for normal sub resource access like as src of a script or image element, while any access that subjects to CORS check will be denied. See [Cross-Origin Resource Sharing](https://developer.mozilla.org/docs/Web/HTTP/CORS) for more information. Specifies the key event type that triggered an `AcceleratorKeyPressed` event. Specifies that the key event type corresponds to window message `WM_KEYDOWN`. Specifies that the key event type corresponds to window message `WM_KEYUP`. Specifies that the key event type corresponds to window message `WM_SYSKEYDOWN`. Specifies that the key event type corresponds to window message `WM_SYSKEYUP`. Specifies memory usage target level of WebView. Specifies normal memory usage target level. Specifies low memory usage target level. Used for inactivate WebView for reduced memory consumption. Mouse event type used by SendMouseInput to convey the type of mouse event being sent to WebView. The values of this enum align with the matching WM_* window messages. Mouse horizontal wheel scroll event, WM_MOUSEHWHEEL. Left button double click mouse event, WM_LBUTTONDBLCLK. Left button down mouse event, WM_LBUTTONDOWN. Left button up mouse event, WM_LBUTTONUP. Mouse leave event, WM_MOUSELEAVE. Middle button double click mouse event, WM_MBUTTONDBLCLK. Middle button down mouse event, WM_MBUTTONDOWN. Middle button up mouse event, WM_MBUTTONUP. Mouse move event, WM_MOUSEMOVE. Right button double click mouse event, WM_RBUTTONDBLCLK. Right button down mouse event, WM_RBUTTONDOWN. Right button up mouse event, WM_RBUTTONUP. Mouse wheel scroll event, WM_MOUSEWHEEL. First or second X button double click mouse event, WM_XBUTTONDBLCLK. First or second X button down mouse event, WM_XBUTTONDOWN. First or second X button up mouse event, WM_XBUTTONUP. Mouse Right Button Down event over a nonclient area, WM_NCRBUTTONDOWN. Mouse Right Button up event over a nonclient area, WM_NCRBUTTONUP. Mouse event virtual keys associated with a COREWEBVIEW2_MOUSE_EVENT_KIND for SendMouseInput. These values can be combined into a bit flag if more than one virtual key is pressed for the event. The values of this enum align with the matching MK_* mouse keys. No additional keys pressed. Left mouse button is down, MK_LBUTTON. Right mouse button is down, MK_RBUTTON. SHIFT key is down, MK_SHIFT. CTRL key is down, MK_CONTROL. Middle mouse button is down, MK_MBUTTON. First X button is down, MK_XBUTTON1 Second X button is down, MK_XBUTTON2 Specifies the reason for moving focus. Specifies that the code is setting focus into WebView. Specifies that the focus is moving due to Tab traversal forward. Specifies that the focus is moving due to Tab traversal backward. Specifies the navigation kind of each navigation. A navigation caused by `CoreWebView2.Reload()`, `location.reload()`, the end user using F5 or other UX, or other reload mechanisms to reload the current document without modifying the navigation history. A navigation back or forward to a different entry in the session navigation history, like via `CoreWebView2.Back()`, `location.back()`, the end user pressing Alt+Left or other UX, or other mechanisms to navigate back or forward in the current session navigation history. A navigation to another document, which can be caused by `CoreWebView2.Navigate()`, `window.location.href = ...`, or other WebView2 or DOM APIs that navigate to a new URI. This enum contains values representing possible regions a given point lies within. The values of this enum align with the matching WM_NCHITTEST* window message return values. A hit test region out of bounds of the WebView2. This has the same value as the Win32 HTNOWHERE A hit test region in the WebView2 which does not have the CSS style `-webkit-app-region: drag` set. This is normal web content that should not be considered part of the app window's title bar. This has the same value as the Win32 HTCLIENT constant. A hit test region in the WebView2 which has the CSS style `-webkit-app-region: drag` set. Web content should use this CSS style to identify regions that should be treated like the app window's title bar. This has the same value as the Win32 HTCAPTION constant. A hit test region in the Webview2 which corresponds to the minimize window control button. A hit test region in the Webview2 which corresponds to the maximize window control button. A hit test region in the Webview2 which corresponds to the close window control button. Specifies the PDF toolbar item types used for the `ICoreWebView2Settings::put_HiddenPdfToolbarItems` method. No item. The save button. The print button. The save as button. The zoom in button. The zoom out button. The rotate button. The fit page button. The page layout button. The bookmarks button. The page select button. The search button. The full screen button. The more settings button. Indicates the type of a permission request. Indicates an unknown permission. Indicates permission to capture audio. Indicates permission to capture video. Indicates permission to access geolocation. Indicates permission to send web notifications. Apps that would like to show notifications should handle `PermissionRequested` events and no browser permission prompt will be shown for notification requests. Note that push notifications are currently unavailable in WebView2. Indicates permission to access generic sensor. Generic Sensor covering ambient-light-sensor, accelerometer, gyroscope, and magnetometer. Indicates permission to read the system clipboard without a user gesture. Indicates permission to automatically download multiple files. Permission is requested when multiple downloads are triggered in quick succession. Indicates permission to read and write to files or folders on the device. Permission is requested when developers use the [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_Access_API) to show the file or folder picker to the end user, and then request "readwrite" permission for the user's selection. Indicates permission to play audio and video automatically on sites. This permission affects the autoplay attribute and play method of the audio and video HTML elements, and the start method of the Web Audio API. See the [Autoplay guide for media and Web Audio APIs](https://developer.mozilla.org/docs/Web/Media/Autoplay_guide) for details. Indicates permission to use fonts on the device. Permission is requested when developers use the [Local Font Access API](https://wicg.github.io/local-font-access/) to query the system fonts available for styling web content. Indicates permission to send and receive system exclusive messages to/from MIDI (Musical Instrument Digital Interface) devices. Permission is requested when developers use the [Web MIDI API](https://developer.mozilla.org/docs/Web/API/Web_MIDI_API) to request access to system exclusive MIDI messages. Indicates permission to open and place windows on the screen. Permission is requested when developers use the [Multi-Screen Window Placement API](https://www.w3.org/TR/window-placement/) to get screen details. Specifies the response to a permission request. Specifies that the default browser behavior is used, which normally prompt users for decision. Specifies that the permission request is granted. Specifies that the permission request is denied. Pointer event type used by SendPointerInput to convey the type of pointer event being sent to WebView. The values of this enum align with the matching WM_POINTER* window messages. Corresponds to WM_POINTERACTIVATE. Corresponds to WM_POINTERDOWN. Corresponds to WM_POINTERENTER. Corresponds to WM_POINTERLEAVE. Corresponds to WM_POINTERUP. Corresponds to WM_POINTERUPDATE. An enum to represent the options for WebView2 color scheme: auto, light, or dark. Auto color scheme. Light color scheme. Dark color scheme. Specifies the collation for a print. The default collation for a printer. Indicate that the collation has been selected for the printed output. Indicate that the collation has not been selected for the printed output. Specifies the color mode for a print. The default color mode for a printer. Indicate that the printed output will be in color. Indicate that the printed output will be in shades of gray. Specifies the print dialog kind. Opens the browser print preview dialog. Opens the system print dialog. Specifies the duplex option for a print. The default duplex for a printer. Print on only one side of the sheet. Print on both sides of the sheet, flipped along the long edge. Print on both sides of the sheet, flipped along the short edge. Specifies the media size for a print. The default media size for a printer. Indicate custom media size that is specific to the printer. The orientation for printing, used by the `Orientation` property on `ICoreWebView2PrintSettings`. Print the page(s) in portrait orientation. Print the page(s) in landscape orientation. Indicates the status for printing. Indicates that the print operation is succeeded. Indicates that the printer is not available. Indicates that the print operation is failed. Specifies the process failure type used in the `ICoreWebView2ProcessFailedEventArgs` interface. The values in this enum make reference to the process kinds in the Chromium architecture. For more information about what these processes are and what they do, see [Browser Architecture - Inside look at modern web browser](https://developers.google.com/web/updates/2018/09/inside-browser-part1). Indicates that the browser process ended unexpectedly. The WebView automatically moves to the Closed state. The app has to recreate a new WebView to recover from this failure. Indicates that the main frame's render process ended unexpectedly. Any subframes in the WebView will be gone too. A new render process is created automatically and navigated to an error page. You can use the `Reload` method to try to recover from this failure. Alternatively, you can `Close` and recreate the WebView. Indicates that the main frame's render process is unresponsive. Renderer process unresponsiveness can happen for the following reasons: There is a **long-running script** being executed. For example, the web content in your WebView might be performing a synchronous XHR, or have entered an infinite loop. Or, the **system is busy**. The `ProcessFailed` event will continue to be raised every few seconds until the renderer process has become responsive again. The application can consider taking action if the event keeps being raised. For example, the application might show UI for the user to decide to keep waiting or reload the page, or navigate away. Indicates that a frame-only render process ended unexpectedly. The process exit does not affect the top-level document, only a subset of the subframes within it. The content in these frames is replaced with an error page in the frame. Your application can communicate with the main frame to recover content in the impacted frames, using `ICoreWebView2ProcessFailedEventArgs2::FrameInfosForFailedProcess` to get information about the impacted frames. Indicates that a utility process ended unexpectedly. The failed process is recreated automatically. Your application does **not** need to handle recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure, including `ProcessDescription`. Indicates that a sandbox helper process ended unexpectedly. This failure is not fatal. Your application does **not** need to handle recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure. Indicates that the GPU process ended unexpectedly. The failed process is recreated automatically. Your application does **not** need to handle recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure. Indicates that a PPAPI plugin process ended unexpectedly. This failure is not fatal. Your application does **not** need to handle recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure, including `ProcessDescription`. Indicates that a PPAPI plugin broker process ended unexpectedly. This failure is not fatal. Your application does **not** need to handle recovery for this event, but can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure. Indicates that a process of unspecified kind ended unexpectedly. Your application can use `ICoreWebView2ProcessFailedEventArgs` and `ICoreWebView2ProcessFailedEventArgs2` to collect information about the failure. Specifies the process failure reason used in the `ICoreWebView2ProcessFailedEventArgs` interface. For process failures where a process has exited, it indicates the type of issue that produced the process exit. An unexpected process failure occurred. The process became unresponsive. This only applies to the main frame's render process. The process was terminated. For example, from Task Manager. The process crashed. Most crashes will generate dumps in the location indicated by `ICoreWebView2Environment11::get_FailureReportFolderPath`. The process failed to launch. The process terminated due to running out of memory. Deprecated. This value is unused. Indicates the process type used in the ICoreWebView2ProcessInfo interface. Indicates the browser process kind. Indicates the render process kind. Indicates the utility process kind. Indicates the sandbox helper process kind. Indicates the GPU process kind. Indicates the PPAPI plugin process kind. Indicates the PPAPI plugin broker process kind. Specifies the WebView2 release channel. Use ReleaseChannels and ChannelSearchKind on CoreWebView2EnvironmentOptions to control which channel the WebView2 loader searches for. ChannelPrimary purposeHow often updated with new featuresStable (WebView2 Runtime)Broad DeploymentMonthlyBetaFlighting with inner rings, automated testingMonthlyDevAutomated testing, selfhosting to test new APIs and featuresWeeklyCanaryAutomated testing, selfhosting to test new APIs and featuresDaily No release channel. Passing only this value to `ReleaseChannels` results in HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND). The stable WebView2 Runtime that is released every 4 weeks. The Beta release channel that is released every 4 weeks, a week before the stable release. The Dev release channel that is released weekly. The Canary release channel that is released daily. Specifies Save As kind selection options for `ICoreWebView2SaveAsUIShowingEventArgs`. For HTML documents, we support 3 Save As kinds: HTML_ONLY, SINGLE_FILE and COMPLETE. For non-HTML documents, you must use DEFAULT. MIME types of `text/html` and `application/xhtml+xml` are considered HTML documents. Default kind to save non-HTML content. If this kind is selected for an HTML page, the behavior is the same as the `HTML_ONLY` kind. Save the page as HTML. Only the top-level document is saved, excluding subresources. Save the page as [MHTML](https://en.wikipedia.org/wiki/MHTML). Save the page as HTML and download the page-related source files (for example: CSS, JavaScript, images, etc.) in a directory with the same filename prefix. Status of a programmatic Save As call. Indicates the result of the `ShowSaveAsUI` method. The ShowSaveAsUI method call completed successfully. By default, the system Save As dialog opens. If `SuppressDefaultDialog` is set to TRUE, the system dialog is skipped. Could not perform Save As because the destination file path is an invalid path. The path is invalid when it is empty, a relative path, or a directory, or when the parent path does not exist. Could not perform Save As because the destination file path already exists and replacing files was not allowed by the `AllowReplace` property. Could not perform Save As because the `Kind` property selection is not supported due to content MIME type or system limits. See the `COREWEBVIEW2_SAVE_AS_KIND` enum for MIME type limits. System limits include when the `HTML_ONLY` kind is selected for an error page at child mode, or when the `COMPLETE` kind is selected and the WebView is running in an App Container. Did not perform Save As because the end user cancelled or the `Cancel` property on `ICoreWebView2SaveAsUIShowingEventArgs` was set to TRUE. Specifies the JavaScript dialog type used in the `ICoreWebView2ScriptDialogOpeningEventHandler` interface. Indicates that the dialog uses the `window.alert` JavaScript function. Indicates that the dialog uses the `window.confirm` JavaScript function. Indicates that the dialog uses the `window.prompt` JavaScript function. Indicates that the dialog uses the `beforeunload` JavaScript event. Set ScrollBar style on `ICoreWebView2EnvironmentOptions` during environment creation. Browser default ScrollBar style Window style fluent overlay scroll bar Please see [Fluent UI](https://developer.microsoft.com/fluentui#/) for more details on fluent UI. Specifies the action type when server certificate error is detected to be used in the `ICoreWebView2ServerCertificateErrorDetectedEventArgs` interface. Indicates to ignore the warning and continue the request with the TLS certificate. This decision is cached for the RequestUri's host and the server certificate in the session. Indicates to reject the certificate and cancel the request. Indicates to display the default TLS interstitial error page to user for page navigations. For others TLS certificate is rejected and the request is cancelled. Specifies the desired access from script to `CoreWebView2SharedBuffer`. Script from web page only has read access to the shared buffer. Script from web page has read and write access to the shared buffer. Indicates the text direction of the notification. Indicates that the notification text direction adopts the browser's language setting behavior. Indicates that the notification text is left-to-right. Indicates that the notification text is right-to-left. Tracking prevention levels. Tracking prevention is turned off. The least restrictive level of tracking prevention. Set to this level to protect against malicious trackers but allows most other trackers and personalize content and ads. See [Current tracking prevention behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) for fine-grained information on what is being blocked with this level and can change with different Edge versions. The default level of tracking prevention. Set to this level to protect against social media tracking on top of malicious trackers. Content and ads will likely be less personalized. See [Current tracking prevention behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) for fine-grained information on what is being blocked with this level and can change with different Edge versions. The most restrictive level of tracking prevention. Set to this level to protect against malicious trackers and most trackers across sites. Content and ads will likely have minimal personalization. This level blocks the most trackers but could cause some websites to not behave as expected. See [Current tracking prevention behavior](/microsoft-edge/web-platform/tracking-prevention#current-tracking-prevention-behavior) for fine-grained information on what is being blocked with this level and can change with different Edge versions. Indicates the error status values for web navigations. Indicates that an unknown error occurred. Indicates that the SSL certificate common name does not match the web address. Indicates that the SSL certificate has expired. Indicates that the SSL client certificate contains errors. Indicates that the SSL certificate has been revoked. Indicates that the SSL certificate is not valid. The certificate may not match the public key pins for the host name, the certificate is signed by an untrusted authority or using a weak sign algorithm, the certificate claimed DNS names violate name constraints, the certificate contains a weak key, the validity period of the certificate is too long, lack of revocation information or revocation mechanism, non-unique host name, lack of certificate transparency information, or the certificate is chained to a [legacy Symantec root](https://security.googleblog.com/2018/03/distrust-of-symantec-pki-immediate.html). Indicates that the host is unreachable. Indicates that the connection has timed out. Indicates that the server returned an invalid or unrecognized response. Indicates that the connection was stopped. Indicates that the connection was reset. Indicates that the Internet connection has been lost. Indicates that a connection to the destination was not established. Indicates that the provided host name was not able to be resolved. Indicates that the operation was canceled. This status code is also used in the following cases: 1) when the app cancels a navigation via NavigationStarting event. 2) For original navigation if the app navigates the WebView2 in a rapid succession away after the load for original navigation commenced, but before it completed. Indicates that the request redirect failed. Indicates that an unexpected error occurred. Indicates that user is prompted with a login, waiting on user action. Initial navigation to a login site will always return this even if app provides credential using BasicAuthenticationRequested. HTTP response status code in this case is 401. See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status. Indicates that user lacks proper authentication credentials for a proxy server. HTTP response status code in this case is 407. See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status. Specifies the web resource request contexts. Specifies all resources. Specifies a document resource. Specifies a CSS resource. Specifies an image resource. Specifies another media resource such as a video. Specifies a font resource. Specifies a script resource. Specifies an XML HTTP request, Fetch and EventSource API communication. Specifies a Fetch API communication. Specifies a TextTrack resource. Specifies an EventSource API communication. Specifies a WebSocket API communication. Specifies a Web App Manifest. Specifies a Signed HTTP Exchange. Specifies a Ping request. Specifies a CSP Violation Report. Specifies an other resource. Specifies the source of `WebResourceRequested` event. Indicates that web resource is requested from main page including dedicated workers, iframes and main script for shared workers. Indicates that web resource is requested from shared worker. Indicates that web resource is requested from service worker. Indicates that web resource is requested from any supported source. A value representing RGBA color (Red, Green, Blue, Alpha) for WebView2. Each component takes a value from 0 to 255, with 0 being no intensity and 255 being the highest intensity. Specifies the intensity of the Alpha ie. opacity value. 0 is transparent, 255 is opaque. Specifies the intensity of the Red color. Specifies the intensity of the Green color. Specifies the intensity of the Blue color. WebView2 enables you to host web content using the latest Microsoft Edge browser and web technology. Gets the process ID of the browser process that hosts the WebView. true if the WebView is able to navigate to a previous page in the navigation history. If CanGoBack changes value, the event is raised. true if the WebView is able to navigate to a next page in the navigation history. If CanGoForward changes value, the event is raised. Indicates if the WebView contains a fullscreen HTML element. Gets the title for the current top-level document. If the document has no explicit title or is otherwise empty, a default that may or may not match the URI of the document is used. Gets the object contains various modifiable settings for the running WebView. Gets the URI of the current top level document. This value potentially changes as a part of the event raised for some cases such as navigating to a different site or fragment navigations. It remains the same for other types of navigations such as page refreshes or history.pushState with the same URL as the current page. ContainsFullScreenElementChanged is raised when the property changes. An HTML element inside the WebView may enter fullscreen to the size of the WebView or leave fullscreen. This event is useful when, for example, a video element requests to go fullscreen. The listener of this event may resize the WebView in response. ContentLoading is raised before any content is loaded, including scripts added with . ContentLoading is not raised if a same page navigation occurs (such as through fragment navigations or history.pushState navigations). This operation follows the and events and precedes the and events. DocumentTitleChanged is raised when the property changes and may be raised before or after the event. FrameNavigationCompleted is raised when a child frame has completely loaded (body.onload has been raised) or loading stopped with error. FrameNavigationStarting is raised when a child frame in the WebView requests permission to navigate to a different URI. Redirects raise this operation as well, and the navigation id is the same as the original one. You may block corresponding navigations until the event handler returns. HistoryChanged is raised for changes to joint session history, which consists of top-level and manual frame navigations. Use HistoryChanged to verify that the or value has changed. HistoryChanged is also raised for using or . HistoryChanged is raised after and . CanGoBack is false for navigations initiated through CoreWebView2Frame APIs if there has not yet been a user gesture. NavigationCompleted is raised when the WebView has completely loaded (body.onload has been raised) or loading stopped with error. NavigationStarting is raised when the WebView main frame is requesting permission to navigate to a different URI. Redirects raise this event as well, and the navigation id is the same as the original one. You may block corresponding navigations until the event handler returns. NewWindowRequested is raised when content inside the WebView requests to open a new window, such as through window.open(). The app can pass a target WebView that is considered the opened window or mark the event as , in which case WebView2 does not open a window. If either Handled or properties are not set, the target content will be opened on a popup window. If a deferral is not taken on the event args, scripts that resulted in the new window that are requested are blocked until the event handler returns. If a deferral is taken, then scripts are blocked until the deferral is completed. On Hololens 2, if the property is not set and the property is not set to true, the WebView2 will navigate to the . If either of these properties are set, the WebView2 will not navigate to the and the the event will continue as normal. PermissionRequested is raised when content in a WebView requests permission to access some privileged resources. If a deferral is not taken on the event args, the subsequent scripts are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. ProcessFailed is raised when a WebView process ends unexpectedly or becomes unresponsive. ProcessFailed is raised when any of the processes in the WebView2 Process Group encounters one of the following conditions: ConditionDetailsUnexpected exit The process indicated by the event args has exited unexpectedly (usually due to a crash). The failure might or might not be recoverable, and some failures are auto-recoverable. Unresponsiveness The process indicated by the event args has become unresponsive to user input. This is only reported for renderer processes, and will run every few seconds until the process becomes responsive again. Note: When the failing process is the browser process, a event will run too. Your application can use to identify which condition and process the event is for, and to collect diagnostics and handle recovery if necessary. For more details about which cases need to be handled by your application, see . :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="ProcessFailed"::: ScriptDialogOpening is raised when a JavaScript dialog (alert, confirm, prompt, or beforeunload) displays for the WebView. This event only is raised if the property is set to false. This event suppresses dialogs or replaces default dialogs with custom dialogs. If a deferral is not taken on the event args, the subsequent scripts are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. SourceChanged is raised when the property changes. SourceChanged is raised when navigating to a different site or fragment navigations. It is not raised for other types of navigations such as page refreshes or history.pushState with the same URL as the current page. This event is raised before for navigation to a new document. WebMessageReceived is raised when the setting is set and the top-level document of the WebView runs window.chrome.webview.postMessage or window.chrome.webview.postMessageWithAdditionalObjects. The postMessage function is void postMessage(object) where object is any object supported by JSON conversion. When postMessage is called, the handler's Invoke method will be called with the object parameter postMessage converted to a JSON string. If the same page calls postMessage multiple times, the corresponding WebMessageReceived events are guaranteed to be fired in the same order. However, if multiple frames call postMessage, there is no guaranteed order. In addition, WebMessageReceived events caused by calls to postMessage are not guaranteed to be sequenced with events caused by DOM APIs. For example, if the page runs chrome.webview.postMessage("message"); window.open(); then the event might be fired before the WebMessageReceived event. If you need the WebMessageReceived event to happen before anything else, then in the WebMessageReceived handler you can post a message back to the page and have the page wait until it receives that message before continuing. WebResourceRequested is raised when the WebView is performing a URL request to a matching URL and resource context filter that was added with . At least one filter must be added for the event to be raised. The web resource requested may be blocked until the event handler returns if a deferral is not taken on the event args. If a deferral is taken, then the web resource requested is blocked until the deferral is completed. If this event is subscribed in the handler it should be called after the new window is set. For more details see . This event is by default raised for file, http, and https URI schemes. This is also raised for registered custom URI schemes. See for more details. WindowCloseRequested is raised when content inside the WebView requested to close the window, such as after window.close() is run. The app should close the WebView and related app window if that makes sense to the app. After the first window.close() call, this event may not fire for any immediate back to back window.close() calls. Causes a navigation of the top level document to the specified URI. The URI to navigate to. For more information, navigate to [Navigation event](/microsoft-edge/webview2/concepts/navigation-events). Note that this operation starts a navigation and the corresponding event is raised sometime after Navigate runs. Initiates a navigation to htmlContent as source HTML of a new document. A source HTML of a new document. The htmlContent parameter may not be larger than 2 MB (2 * 1024 * 1024 bytes) in total size. The origin of the new page is about:blank. webView.CoreWebView2.SetVirtualHostNameToFolderMapping( "appassets.example", "assets", CoreWebView2HostResourceAccessKind.DenyCors); string htmlContent = @"

Click me

"; webview.NavigateToString(htmlContent);
Adds the provided JavaScript to a list of scripts that should be run after the global object has been created, but before the HTML document has been parsed and before any other script included by the HTML document is run. The JavaScript code to be run.A script ID that may be passed when calling . The injected script will apply to all future top level document and child frame navigations until removed with . This is applied asynchronously and you must wait for the returned IAsyncOperation to complete before you can be sure that the script is ready to execute on future navigations. If the method is run in handler, it should be called before the new window is set. For more details see . Note that if an HTML document has sandboxing of some kind via [sandbox](https://developer.mozilla.org/docs/Web/HTML/Element/iframe#attr-sandbox) properties or the [Content-Security-Policy HTTP header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy) this will affect the script run here. So, for example, if the allow-modals keyword is not set then calls to the alert function will be ignored. Removes the corresponding JavaScript added via with the specified script ID. The ID corresponds to the JavaScript code to be removed from the list of scripts. Both use and this method in handler at the same time sometimes causes trouble. Since invalid scripts will be ignored, the script IDs you got may not be valid anymore. Runs JavaScript code from the javaScript parameter in the current top-level document rendered in the WebView. The JavaScript code to be run in the current top-level document rendered in the WebView.A JSON encoded string that represents the result of running the provided JavaScript. If the result is undefined, contains a reference cycle, or otherwise is not able to be encoded into JSON, the JSON null value is returned as the "null" string. A function that has no explicit return value returns undefined. If the script that was run throws an unhandled exception, then the result is also null. This method is applied asynchronously. If the method is run after the event during a navigation, the script runs in the new document when loading it, around the time is run. This operation works even if is set to false. Captures an image of what WebView is displaying. The format of the image to be captured.The stream to which the resulting image binary data is written. When CapturePreviewAsync finishes writing to the stream, the Invoke method on the provided handler parameter is called. This method fails if called before the first event. For example if this is called in the event for the first navigation it will fail. For subsequent navigations, the method may not fail, but will not capture an image of a given webpage until the event has been fired for it. Any call to this method prior to that will result in a capture of the page being navigated away from. Reloads the current page. This is similar to navigating to the URI of current top level document including all navigation events firing and respecting any entries in the HTTP cache. But, the back or forward history will not be modified. Posts the specified webMessageAsJson to the top level document in this WebView. The web message to be posted to the top level document in this WebView. The event args is an instance of MessageEvent. The setting must be true or the message will not be sent. The event arg's data property of the event arg is the webMessageAsJson string parameter parsed as a JSON string into a JavaScript object. The event arg's source property of the event arg is a reference to the window.chrome.webview object. For information about sending messages from the HTML document in the WebView to the host, navigate to . The message is sent asynchronously. If a navigation occurs before the message is posted to the page, the message is not be sent. Runs the message event of the window.chrome.webview of the top-level document. JavaScript in that document may subscribe and unsubscribe to the event using the following code: window.chrome.webview.addEventListener('message', handler) window.chrome.webview.removeEventListener('message', handler) Posts a message that is a simple string rather than a JSON string representation of a JavaScript object. The web message to be posted to the top level document in this WebView. This behaves in exactly the same manner as , but the data property of the event arg of the window.chrome.webview message is a string with the same value as webMessageAsString. Use this instead of if you want to communicate using simple strings rather than JSON objects. Runs an asynchronous DevToolsProtocol method. The full name of the method in the format {domain}.{method}.A JSON formatted string containing the parameters for the corresponding method.A JSON string that represents the method's return object. For more information about available methods, navigate to [DevTools Protocol Viewer](https://aka.ms/DevToolsProtocolDocs). The returned task is completed when the method asynchronously completes and will return the method's return object as a JSON string. Note even though WebView2 dispatches the CDP messages in the order called, CDP method calls may be processed out of order. If you require CDP methods to run in a particular order, you should await for the previous method call. Navigates the WebView to the previous page in the navigation history. Navigates the WebView to the next page in the navigation history. Gets a DevTools Protocol event receiver that allows you to subscribe to a DevToolsProtocol event. The full name of the event in the format {domain}.{event}.A Devtools Protocol event receiver. For more information about DevToolsProtocol events description and event args, navigate to [DevTools Protocol Viewer](https://aka.ms/DevToolsProtocolDocs). Stops all navigations and pending resource fetches. Does not stop scripts. Adds the provided host object to script running in the WebView with the specified name. The name of the host object.The host object to be added to script. Host objects are exposed as host object proxies via window.chrome.webview.hostObjects.{name}. Host object proxies are promises and will resolve to an object representing the host object. Only the COM visible objects/properties/methods can be accessed from script. The app can control which part of .NET objects are exposed using . JavaScript code in the WebView will be able to access appObject as following and then access attributes and methods of appObject. Note that while simple types, IDispatch and array are supported, and IUnknown objects that also implement IDispatch are treated as IDispatch, generic IUnknown, VT_DECIMAL, or VT_RECORD variant is not supported. Remote JavaScript objects like callback functions are represented as an VT_DISPATCH VARIANT with the object implementing IDispatch. The JavaScript callback method may be invoked using DISPID_VALUE for the DISPID. Such callback method invocations will return immediately and will not wait for the JavaScript function to run and so will not provide the return value of the JavaScript function. Nested arrays are supported up to a depth of 3. Arrays of by reference types are not supported. VT_EMPTY and VT_NULL are mapped into JavaScript as null. In JavaScript null and undefined are mapped to VT_EMPTY. Additionally, all host objects are exposed as window.chrome.webview.hostObjects.sync.{name}. Here the host objects are exposed as synchronous host object proxies. These are not promises and calls to functions or property access synchronously block running script waiting to communicate cross process for the host code to run. Accordingly this can result in reliability issues and it is recommended that you use the promise based asynchronous window.chrome.webview.hostObjects.{name} API described above. Synchronous host object proxies and asynchronous host object proxies can both proxy the same host object. Remote changes made by one proxy will be reflected in any other proxy of that same host object whether the other proxies and synchronous or asynchronous. While JavaScript is blocked on a synchronous call to native code, that native code is unable to call back to JavaScript. Attempts to do so will fail with HRESULT_FROM_WIN32(ERROR_POSSIBLE_DEADLOCK). Host object proxies are JavaScript Proxy objects that intercept all property get, property set, and method invocations. Properties or methods that are a part of the Function or Object prototype are run locally. Additionally any property or method in the array chrome.webview.hostObjects.options.forceLocalProperties will also be run locally. This defaults to including optional methods that have meaning in JavaScript like toJSON and Symbol.toPrimitive. You can add more to this array as required. There's a method chrome.webview.hostObjects.cleanupSome that will best effort garbage collect host object proxies. The chrome.webview.hostObjects.options object provides the ability to change some functionality of host objects. Options propertyDetailsforceLocalProperties This is an array of host object property names that will be run locally, instead of being called on the native host object. This defaults to then, toJSON, Symbol.toString, and Symbol.toPrimitive. You can add other properties to specify that they should be run locally on the JavaScript host object proxy. log This is a callback that will be called with debug information. For example, you can set this to console.log.bind(console) to have it print debug information to the console to help when troubleshooting host object usage. By default this is null. shouldSerializeDates By default this is false, and JavaScript Date objects will be sent to host objects as a string using JSON.stringify. You can set this property to true to have Date objects properly serialize as a System.DateTime when sending to the .NET host object, and have System.DateTime properties and return values create a JavaScript Date object. defaultSyncProxy When calling a method on a synchronous proxy, the result should also be a synchronous proxy. But in some cases, the sync/async context is lost (for example, when providing to native code a reference to a function, and then calling that function in native code). In these cases, the proxy will be asynchronous, unless this property is set. forceAsyncMethodMatches This is an array of regular expressions. When calling a method on a synchronous proxy, the method call will be performed asynchronously if the method name matches a string or regular expression in this array. Setting this value to Async will make any method that ends with Async be an asynchronous method call. If an async method doesn't match here and isn't forced to be asynchronous, the method will be invoked synchronously, blocking execution of the calling JavaScript and then returning the resolution of the promise, rather than returning a promise. ignoreMemberNotFoundError By default, an exception is thrown when attempting to get the value of a proxy property that doesn't exist on the corresponding native class. Setting this property to true switches the behavior to match Chakra WinRT projection (and general JavaScript) behavior of returning undefined with no error. shouldPassTypedArraysAsArrays By default, typed arrays are passed to the host as IDispatch. To instead pass typed arrays to the host as array, set this to true. Host object proxies additionally have the following methods: Method nameDetailsapplyHostFunction, getHostProperty, setHostProperty Perform a method invocation, property get, or property set on the host object. You can use these to explicitly force a method or property to run remotely if there is a conflicting local method or property. For instance, proxy.toString() will run the local toString method on the proxy object. But proxy.applyHostFunction('toString') runs toString on the host proxied object instead. getLocalProperty, setLocalProperty Perform property get, or property set locally. You can use these methods to force getting or setting a property on the host object proxy itself rather than on the host object it represents. For instance, proxy.unknownProperty will get the property named unknownProperty from the host proxied object. But proxy.getLocalProperty('unknownProperty') will get the value of the property unknownProperty on the proxy object itself. addEventListener This method only exists on proxies for .NET objects. Bind the JavaScript handler to the C# event, so that the JavaScript handler can be called through the C# event. For example, chrome.webview.hostObjects.sample.addEventListener('TestEvent', () => { alert('Invoked from remote');}); bind an anonymous JavaScript function to a C# event called 'TestEvent'. When calling TestEvent?.Invoke() on C# side, the JavaScript function that was just bound will be called asynchronously. It allows adding more than one handler for an event, but if the handler is already in the list of event handler, it will not be added a second time. If the host object cannot find the event with the name passed in by the addEventListener function or it is no public or its return type is not void, an exception will be thrown. If the count and type of C# event's parameters do not match the count and type of JavaScript handler, invoke addEventListener will be successful but an exception will be passed to JavaScript when invoke the event on C# side. If the host object has defined addEventListener function, use the defined function rather than the additionally addEventListener function. removeEventListener This method only exists on proxies for .NET objects. Removes a handler previously bound with addEventListener(). If the handler does not exist in the list of event handler, nothing will happen. If the host object cannot find the event with the name passed in by the removeEventListener function or it is no public, an exception will be thrown. If the host object has defined removeEventListener function, use the defined function rather than the additionally removeEventListener function. sync Asynchronous host object proxies expose a sync method which returns a promise for a synchronous host object proxy for the same host object. For example, chrome.webview.hostObjects.sample.methodCall() returns an asynchronous host object proxy. You can use the sync method to obtain a synchronous host object proxy instead: const syncProxy = await chrome.webview.hostObjects.sample.methodCall().sync()async Synchronous host object proxies expose an async method which blocks and returns an asynchronous host object proxy for the same host object. For example, chrome.webview.hostObjects.sync.sample.methodCall() returns a synchronous host object proxy. Calling the async method on this blocks and then returns an asynchronous host object proxy for the same host object: const asyncProxy = chrome.webview.hostObjects.sync.sample.methodCall().async()then Asynchronous host object proxies have a then method. This allows them to be awaitable. then will return a promise that resolves with a representation of the host object. If the proxy represents a JavaScript literal then a copy of that is returned locally. If the proxy represents a function then a non-awaitable proxy is returned. If the proxy represents a JavaScript object with a mix of literal properties and function properties, then the a copy of the object is returned with some properties as host object proxies. cancelPromise This method attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise will get rejected. cancelPromise supports cancellation of IAsyncOperation and IAsyncAction methods. If the promise is successfully canceled, then calling await on the promise will throw. For example, chrome.webview.hostObjects.cancelPromise(promise); await promise; will throw with "Promise Canceled". Once a promise has been canceled, a subsequent cancel on the same promise will throw an exception as well. All other property and method invocations (other than the above Remote object proxy methods, forceLocalProperties list, and properties on Function and Object prototypes) are run remotely. Asynchronous host object proxies return a promise representing asynchronous completion of remotely invoking the method, or getting the property. The promise resolves after the remote operations complete and the promises resolve to the resulting value of the operation. Synchronous host object proxies work similarly but block JavaScript execution and wait for the remote operation to complete. Setting a property on an asynchronous host object proxy works slightly differently. The set returns immediately and the return value is the value that will be set. This is a requirement of the JavaScript Proxy object. If you need to asynchronously wait for the property set to complete, use the setHostProperty method which returns a promise as described above. Synchronous object property set property synchronously blocks until the property is set. Exposing host objects to script has security risk. Please follow [best practices](/microsoft-edge/webview2/concepts/security). To create a [IDispatch](/windows/win32/api/oaidl/nn-oaidl-idispatch) implementing class in C# use the following attributes on each class you intend to expose. // Bridge and BridgeAnotherClass are C# classes that implement IDispatch and works with AddHostObjectToScript. [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] public class BridgeAnotherClass { // Sample property. public string Prop { get; set; } = "Example"; } [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] public class Bridge { public string Func(string param) { return "Example: " + param; } public BridgeAnotherClass AnotherObject { get; set; } = new BridgeAnotherClass(); // Sample indexed property. [System.Runtime.CompilerServices.IndexerName("Items")] public string this[int index] { get { return m_dictionary[index]; } set { m_dictionary[index] = value; } } private Dictionary<int, string> m_dictionary = new Dictionary<int, string>(); } Then add instances of those classes via : webView.CoreWebView2.AddHostObjectToScript("bridge", new Bridge()); And then in script you can call the methods, and access those properties of the objects added via . Note that `CoreWebView2.AddHostObjectToScript` only applies to the top-level document and not to frames. To add host objects to frames use `CoreWebView2Frame.AddHostObjectToScript`. // Find added objects on the hostObjects property const bridge = chrome.webview.hostObjects.bridge; // Call a method and pass in a parameter. // The result is another proxy promise so you must await to get the result. console.log(await bridge.Func("testing...")); // A property may be another object as long as its class also implements // IDispatch. // Getting a property also gets a proxy promise you must await. const propValue = await bridge.AnotherObject.Prop; console.log(propValue); // Indexed properties let index = 123; bridge[index] = "test"; let result = await bridge[index]; console.log(result); Removes the host object specified by the name so that it is no longer accessible from JavaScript code in the WebView. The name of the host object to be removed. While new access attempts are denied, if the object is already obtained by JavaScript code in the WebView, the JavaScript code continues to have access to that object. Running this method for a name that is already removed or never added fails. Opens the DevTools window for the current document in the WebView. Does nothing if run when the DevTools window is already open. Warning: This method is deprecated and does not behave as expected for iframes. Please use instead. Warning: This method and `CoreWebView2.AddWebResourceRequestedFilter(string, CoreWebView2WebResourceContext)` are deprecated. Please use and instead. BasicAuthenticationRequested event is raised when WebView encounters a Basic HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Authentication, a Digest HTTP Authentication request as described in https://developer.mozilla.org/docs/Web/HTTP/Headers/Authorization#digest, an NTLM authentication or a Proxy Authentication request. The host can provide a response with credentials for the authentication or cancel the request. If the host sets the Cancel property to false but does not provide either UserName or Password properties on the Response property, then WebView2 will show the default authentication challenge dialog prompt to the user. ContextMenuRequested is raised when a context menu is requested by the user and the content inside WebView hasn't disabled context menus. The host has the option to create their own context menu with the information provided in the event or can add items to or remove items from WebView context menu. If the host doesn't handle the event, WebView will display the default context menu. Runs an asynchronous DevToolsProtocol method for a specific session of an attached target. The sessionId for an attached target. null or empty string is treated as the session for the default target for the top page.The full name of the method in the format {domain}.{method}.A JSON formatted string containing the parameters for the corresponding method.A JSON string that represents the method's return object. There could be multiple DevToolsProtocol targets in a WebView. Besides the top level page, iframes from different origin and web workers are also separate targets. Attaching to these targets allows interaction with them. When the DevToolsProtocol is attached to a target, the connection is identified by a sessionId. To use this API, you must set the flatten parameter to true when calling Target.attachToTarget or Target.setAutoAttachDevToolsProtocol method. Using Target.setAutoAttach is recommended as that would allow you to attach to dedicated worker targets, which are not discoverable via other APIs like Target.getTargets. For more information about targets and sessions, navigate to [Chrome DevTools Protocol - Target domain]( https://chromedevtools.github.io/devtools-protocol/tot/Target). For more information about available methods, navigate to [DevTools Protocol Viewer](https://aka.ms/DevToolsProtocolDocs). The handler's Invoke method will be called when the method asynchronously completes. Invoke will be called with the method's return object as a JSON string. The current text of the statusbar as defined by [Window.statusbar](https://developer.mozilla.org/docs/Web/API/Window/statusbar). StatusBarTextChanged event is raised when the text in the [Window.statusbar](https://developer.mozilla.org/docs/Web/API/Window/statusbar) changes. When the event is fired use the property to get the current statusbar text. Events which cause causes can be anything from hover, url events, and others. There is not a finite list on how to cause the statusbar to change. The developer must create the status bar and set the text. The associated object of . The ServerCertificateErrorDetected event is raised when the WebView2 cannot verify server's digital certificate while loading a web page. This event will raise for all web resources and follows the event. If you don't handle the event, WebView2 will show the default TLS interstitial error page to the user for navigations, and for non-navigations the web request is cancelled. Note that WebView2 before raising `ServerCertificateErrorDetected` raises a event with as FALSE and any of the below WebErrorStatuses that indicate a certificate failure. For more details see and handle ServerCertificateErrorDetected event or show the default TLS interstitial error page to the user according to the app needs. WebView2 caches the response when action is for the RequestUri's host and the server certificate in the session and the event won't be raised again. To raise the event again you must clear the cache using . Clears all cached decisions to proceed with TLS certificate errors from the event for all WebView2's sharing the same session. Get the Uri as a string of the current Favicon. This will be an empty string if the page does not have a Favicon. Raised when the Favicon has changed. This can include when a new page is loaded and thus by default no icon is set or the icon is set for the page by DOM or JavaScript. The first argument is the Webview2 which saw the changed Favicon and the second is null. Get the downloaded Favicon image for the current page and copy it to the image stream. The format to retrieve the Favicon in. An IStream populated with the downloaded Favicon. Print the current web page asynchronously to the specified printer with the provided settings. See for description of settings. Passing null for printSettings results in default print settings used. The method will return as if printerName doesn't match with the name of any installed printers on the user OS. The method will throw ArgumentException if the caller provides invalid settings for a given printer. The async Print operation completes when it finishes printing to the printer. Only one Printing operation can be in progress at a time. If Print is called while a or or job is in progress, throws exception. This is only for printing operation on one webview. ErrorPrintStatusNotesNoPrint operation succeeded.NoIf specified printer is not found or printer status is not available, offline or error state.NoPrint operation is failed. ArgumentExceptionIf the caller provides invalid settings for the specified printer.ExceptionPrint operation is failed as printing job already in progress. :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="PrintToPrinter"::: Opens the print dialog to print the current web page. See for descriptions of print dialog kinds. Invoking browser or system print dialog doesn't open new print dialog if it is already open. Provides the Pdf data of current web page asynchronously for the provided settings. Stream will be rewound to the start of the pdf data. See for description of settings. Passing null for printSettings results in default print settings used. The async PrintToPdfStream operation completes when it finishes writing to the stream. Only one Printing operation can be in progress at a time. If is called while a or or job is in progress, the throws an exception. This is only for printing operation on one webview. Share a shared buffer object with script of the main frame in the WebView. The object to be shared with script.The desired given to script.Additional data to be send to script. If it is not null or empty string, and it is not a valid JSON string, will be thrown. The script will receive a sharedbufferreceived event from chrome.webview. The event arg for that event will have the following methods and properties. PropertyDescriptiongetBuffer()A method that returns an ArrayBuffer object with the backing content from the shared buffer.additionalDataAn object as the result of parsing additionalDataAsJson as JSON string. This property will be undefined if additionalDataAsJson is nullptr or empty string.sourceWith a value set as chrome.webview object. If access is , the script will only have read access to the buffer. If the script tries to modify the content in a read only buffer, it will cause an access violation in WebView renderer process and crash the renderer process. If the shared buffer is already closed, the API throws COMException with error code of RO_E_CLOSED. The script code should call chrome.webview.releaseBuffer with the shared buffer as the parameter to release underlying resources as soon as it does not need access to the shared buffer any more. The application can post the same shared buffer object to multiple web pages or iframes, or post to the same web page or iframe multiple times. Each PostSharedBufferToScript will create a separate ArrayBuffer object with its own view of the memory and is separately released. The underlying shared memory will be released when all the views are released. Sharing a buffer to script has security risk. You should only share buffer with trusted site. If a buffer is shared to a untrusted site, possible sensitive information could be leaked. If a buffer is shared as modifiable by the script and the script modifies it in an unexpected way, it could result in corrupted data that might even crash the application. The example code shows how to send data to script for one time read only consumption. :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="OneTimeShareBuffer"::: :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/assets/sharedBuffer.html" id="ShareBufferScriptCode_1"::: :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/assets/sharedBuffer.html" id="ShareBufferScriptCode_2"::: LaunchingExternalUriScheme is raised when a navigation request is made to a URI scheme that is registered with the OS. The event handler may suppress the default dialog or replace the default dialog with a custom dialog. If a is not taken on the event args, the external URI scheme launch is blocked until the event handler returns. If a deferral is taken, the external URI scheme launch is blocked until the is completed. The host also has the option to cancel the URI scheme launch. The and events will be raised, regardless of whether the property is set to true or false. The event will be raised with the property set to false and the property set to CoreWebView2WebErrorStatus.ConnectionAborted regardless of whether the host sets the property. The , and events will not be raised for this navigation to the external URI scheme regardless of the property. The event will be raised after the event and before the event. The default will also be updated upon navigation to an external URI scheme. If a setting on the interface has been changed, navigating to an external URI scheme will trigger the to update. The WebView2 may not display the default dialog based on user settings, browser settings, and whether the origin is determined as a [trustworthy origin](https://w3c.github.io/webappsec-secure-contexts#potentially-trustworthy-origin); however, the event will still be raised. If the request is initiated by a cross-origin frame without a user gesture, the request will be blocked and the `LaunchingExternalUriScheme` event will not be raised. Desired of a WebView. An app may set to indicate desired memory consumption level of WebView. Scripts will not be impacted and continue to run. This is useful for inactive apps that still want to run scripts and/or keep network connections alive and therefore could not call and to reduce memory consumption. These apps can set memory usage target level to CoreWebView2MemoryUsageTargetLevel.Low when the app becomes inactive, and set back to CoreWebView2MemoryUsageTargetLevel.Normal when the app becomes active. It is not necessary to set CoreWebView2Controller's IsVisible property to false when setting the property. It is a best effort operation to change memory usage level, and the API will return before the operation completes. Setting the level to `CoreWebView2MemoryUsageTargetLevel.Low` could potentially cause memory for some WebView browser processes to be swapped out to disk in some circumstances. It is a best effort to reduce memory usage as much as possible. If a script runs after its related memory has been swapped out, the memory will be swapped back in to ensure the script can still run, but performance might be impacted. Therefore, the app should set the level back to `CoreWebView2MemoryUsageTargetLevel.Normal` when the app becomes active again. Setting memory usage target level back to normal will not happen automatically. An app should choose to use either the combination of and or the combination of setting MemoryUsageTargetLevel to `CoreWebView2MemoryUsageTargetLevel.Low` and `CoreWebView2MemoryUsageTargetLevel.Normal`. It is not advisable to mix them. Trying to set while suspended will be ignored. The and methods will change the . will automatically set to `CoreWebView2MemoryUsageTargetLevel.Low` while on suspended WebView will automatically set to `CoreWebView2MemoryUsageTargetLevel.Normal`. Calling when the WebView is not suspended would not change . Gets the object associated with this . Exposes the used to create this . DOMContentLoaded is raised when the initial HTML document has been parsed. This aligns with the the document's DOMContentLoaded event in HTML. WebResourceResponseReceived is raised when the WebView receives the response for a request for a web resource (any URI resolution performed by the WebView; such as HTTP/HTTPS, file and data requests from redirects, navigations, declarations in HTML, implicit Favicon lookups, and fetch API usage in the document). The host app can use this event to view the actual request and response for a web resource. There is no guarantee about the order in which the WebView processes the response and the host app's handler runs. The app's handler will not block the WebView from processing the response. The event args include the as sent by the wire and received, including any additional headers added by the network stack that were not be included as part of the associated event, such as Authentication headers. Navigates using a constructed object. The constructed web resource object to provide post data or additional request headers during navigation. The headers in the override headers added by WebView2 runtime except for Cookie headers. Method can only be either GET or POST. Provided post data will only be sent only if the method is POST and the uri scheme is HTTP(S). The unique identifier of the main frame. It's the same kind of ID as with the and . FrameId may not be valid if has not done any navigation. It's safe to get this value during or after the first event. Otherwise, it could return the invalid frame Id 0. Runs JavaScript code from the javaScript parameter in the current top-level document rendered in the WebView, The result of the execution is returned asynchronously in the object which has methods and properties to obtain the successful result of script execution as well as any unhandled JavaScript exceptions. A URI to be added to the event.A resource context filter to be added to the event.A mask of one or more s. A web resource request with a resource context that matches this filter's resource context and a URI that matches this filter's URI wildcard string for corresponding request sources will be raised via the event. To receive all raised events filters have to be added before main page navigation. The uri parameter value is a wildcard string matched against the URI of the web resource request. This is a glob style wildcard string in which a * matches zero or more characters and a ? matches exactly one character. These wildcard characters can be escaped using a backslash just before the wildcard character in order to represent the literal * or ?. The matching occurs over the URI as a whole string and not limiting wildcard matches to particular parts of the URI. The wildcard filter is compared to the URI after the URI has been normalized, any URI fragment has been removed, and non-ASCII hostnames have been converted to punycode. Specifying a null for the uri is equivalent to an empty string which matches no URIs. For more information about resource context filters, navigate to . URI Filter StringRequest URIMatchNotes*https://contoso.com/a/b/cYesA single * will match all URIs*://contoso.com/*https://contoso.com/a/b/cYesMatches everything in contoso.com across all schemes*://contoso.com/*https://example.com/?https://contoso.com/YesBut also matches a URI with just the same text anywhere in the URIexamplehttps://contoso.com/exampleNoThe filter does not perform partial matches*examplehttps://contoso.com/exampleYesThe filter matches across URI parts *examplehttps://contoso.com/path/?exampleYesThe filter matches across URI parts*examplehttps://contoso.com/path/?query#exampleNoThe filter is matched against the URI with no fragment*examplehttps://exampleNoThe URI is normalized before filter matching so the actual URI used for comparison is https://example.com/*example/https://exampleYesJust like above, but this time the filter ends with a / just like the normalized URIhttps://xn--qei.example/https://❤.example/YesNon-ASCII hostnames are normalized to punycode before wildcard comparisonhttps://❤.example/https://xn--qei.example/NoNon-ASCII hostnames are normalized to punycode before wildcard comparison To form the requestSourceKinds parameter OR operation(s) can be applied to multiple CoreWebView2WebResourceRequestSourceKind to create a mask representing those source kinds. API will fail with E_INVALIDARG if requestSourceKinds equals to zero. Because service workers and shared workers run separately from any one HTML document their WebResourceRequested will be raised for all CoreWebView2s that have appropriate filters added in the corresponding CoreWebView2Environment. You should only add a WebResourceRequested filter for or on one CoreWebView2 to avoid handling the same WebResourceRequested event multiple times. Removes a matching WebResource filter that was previously added for the `WebResourceRequested` event. If the same filter was added multiple times, then it must be removed as many times as it was added for the removal to be effective. Returns `E_INVALIDARG` for a filter that was not added or is already removed. If the filter was added for multiple requestSourceKinds and removed just for one of them the filter remains for the non-removed requestSourceKinds. Async method to programmatically trigger a Save As action for the currently loaded document. It opens a system modal dialog by default. If the property is `TRUE`, the system dialog is not opened. This method can return . ScreenCaptureStarting event is raised when the [Screen Capture API](https://www.w3.org/TR/screen-capture/) is requested by the user using getDisplayMedia(). If a deferral is not taken on the event args, the subsequent scripts are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. This event will be raised during system FileTypePolicy checking the dangerous file extension list. Developers can specify their own logic for determining whether to allow a particular type of file to be saved from the document origin URI. Developers can also determine the save decision based on other criteria. Here are two properties in to manage the decision, and . Table of Properties' value and result: CancelSaveSuppressDefaultPolicyResultFalseFalsePerform the default policy check. It may show the security warning UI if the file extension is dangerous.FalseTrueSkip the default policy check and the possible security warning. Start saving or downloading.TrueAnySkip the default policy check and the possible security warning. Abort save or download. Add an event handler for the `NotificationReceived` event for non-persistent notifications. If a deferral is not taken on the event args, the subsequent scripts after the DOM notification creation call (i.e. `Notification()`) are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. Whether WebView is suspended. True when WebView is suspended, from the time when has completed successfully until WebView is resumed. An app may call this API to have the WebView2 consume less memory. This is useful when a Win32 app becomes invisible, or when a Universal Windows Platform app is being suspended, during the suspended event handler before completing the suspended event. The property must be false when the API is called. Otherwise, the API throws COMException with error code of HRESULT_FROM_WIN32(ERROR_INVALID_STATE). Suspending is similar to putting a tab to sleep in the Edge browser. Suspending pauses WebView script timers and animations, minimizes CPU usage for the associated browser renderer process and allows the operating system to reuse the memory that was used by the renderer process for other processes. Note that Suspend is best effort and considered completed successfully once the request is sent to browser renderer process. If there is a running script, the script will continue to run and the renderer process will be suspended after that script is done. See [Sleeping Tabs FAQ](https://techcommunity.microsoft.com/t5/articles/sleeping-tabs-faq/m-p/1705434) for conditions that might prevent WebView from being suspended. In those situations, the result of the async task is false. The WebView will be automatically resumed when it becomes visible. Therefore, the app normally does not have to call explicitly. The app can call and then periodically for an invisible WebView so that the invisible WebView can sync up with latest data and the page ready to show fresh content when it becomes visible. All WebView APIs can still be accessed when a WebView is suspended. Some APIs like Navigate will auto resume the WebView. To avoid unexpected auto resume, check property before calling APIs that might change WebView state. Resumes the WebView so that it resumes activities on the web page. This API can be called while the WebView2 controller is invisible. The app can interact with the WebView immediately after . WebView will be automatically resumed when it becomes visible. Sets a mapping between a virtual host name and a folder path to make available to web sites via that host name. A virtual host name.A folder path name to be mapped to the virtual host name. The length must not exceed the Windows MAX_PATH limit.The level of access to resources under the virtual host from other sites. After setting the mapping, documents loaded in the WebView can use HTTP or HTTPS URLs at the specified host name specified by hostName to access files in the local folder specified by folderPath. This mapping applies to both top-level document and iframe navigations as well as subresource references from a document. This also applies to dedicated and shared worker scripts but does not apply to service worker scripts. Due to a current implementation limitation, media files accessed using virtual host name can be very slow to load. As the resource loaders for the current page might have already been created and running, changes to the mapping might not be applied to the current page and a reload of the page is needed to apply the new mapping. Both absolute and relative paths are supported for folderPath. Relative paths are interpreted as relative to the folder where the exe of the app is in. For example, after calling SetVirtualHostNameToFolderMapping("appassets.example", "assets", CoreWebView2HostResourceAccessKind.Deny);, navigating to https://appassets.example/my-local-file.html will show content from my-local-file.html in the assets subfolder located on disk under the same path as the app's executable file. DOM elements that want to reference local files will have their host reference virtual host in the source. If there are multiple folders being used, define one unique virtual host per folder. You should typically choose virtual host names that are never used by real sites. If you own a domain such as example.com, another option is to use a subdomain reserved for the app (like my-app.example.com). [RFC 6761](https://tools.ietf.org/html/rfc6761) has reserved several special-use domain names that are guaranteed to not be used by real sites (for example, .example, .test, and .invalid). Note that using .local as the top-level domain name will work but can cause a delay during navigations. You should avoid using .local if you can. Apps should use distinct domain names when mapping folder from different sources that should be isolated from each other. For instance, the app might use app-file.example for files that ship as part of the app, and book1.example might be used for files containing books from a less trusted source that were previously downloaded and saved to the disk by the app. The host name used in the APIs is canonicalized using Chromium's host name parsing logic before being used internally. For more information see [HTML5 2.6 URLs](https://dev.w3.org/html5/spec-LC/urls.html). All host names that are canonicalized to the same string are considered identical. For example, EXAMPLE.COM and example.com are treated as the same host name. An international host name and its Punycode-encoded host name are considered the same host name. There is no DNS resolution for host name and the trailing '.' is not normalized as part of canonicalization. Therefore example.com and example.com. are treated as different host names. Similarly, virtual-host-name and virtual-host-name.example.com are treated as different host names even if the machine has a DNS suffix of example.com. Specify the minimal cross-origin access necessary to run the app. If there is not a need to access local resources from other origins, use . webView.CoreWebView2.SetVirtualHostNameToFolderMapping( "appassets.example", "assets", CoreWebView2HostResourceAccessKind.DenyCors); webView.Source = new Uri("https://appassets.example/index.html"); This in an example on how to embed a local image. For more information see . webView.CoreWebView2.SetVirtualHostNameToFolderMapping( "appassets.example", "assets", CoreWebView2HostResourceAccessKind.DenyCors); string c_navString = ""; webview.NavigateToString(c_navString); Clears a host name mapping for local folder that was added by . The host name to be removed from the mapping. DownloadStarting is raised when a download has begun, blocking the default download dialog, but not blocking the progress of the download. The host can choose to cancel a download, change the result file path, and hide the default download dialog. If download is not handled or canceled, the download is saved to the default path after the event completes with default download dialog shown. FrameCreated is raised when a new iframe is created. Handle this event to get access to objects. Use the to listen for when this iframe goes away. ClientCertificateRequested is raised when WebView2 is making a request to an HTTP server that needs a client certificate for HTTP authentication. Read more about HTTP client certificates at [RFC 8446 The Transport Layer Security (TLS) Protocol Version 1.3](https://tools.ietf.org/html/rfc8446). The host have several options for responding to client certificate requests: ScenarioHandledCancelSelectedCertificateRespond to server with a certificateTrueFalseMutuallyTrustedCertificate valueRespond to server without certificateTrueFalsenullDisplay default client certificate selection dialog promptFalseFalsen/aCancel the requestn/aTruen/a If the host don't handle the event, WebView2 will show the default client certificate selection dialog prompt to the user. Opens the Browser Task Manager view as a new window in the foreground. If the Browser Task Manager is already open, this will bring it into the foreground. WebView2 currently blocks the Shift+Esc shortcut for opening the task manager. An end user can open the browser task manager manually via the Browser task manager entry of the DevTools window's title bar's context menu. Print the current page to PDF asynchronously with the provided settings. See for description of settings. Passing null for printSettings results in default print settings used. Use resultFilePath to specify the path to the PDF file. The host should provide an absolute path, including file name. If the path points to an existing file, the file will be overwritten. If the path is not valid, the method fails. The async PrintToPdf operation completes when the data has been written to the PDF file. If the application exits before printing is complete, the file is not saved. Only one PrintToPdf operation can be in progress at a time. If PrintToPdf is called while a print to PDF operation is in progress, the IAsyncOperation completes and returns false. Indicates whether any audio output from this CoreWebView2 is playing. true if audio is playing even if is true. Indicates whether all audio output from this CoreWebView2 is muted or not. Set to true will mute this CoreWebView2, and set to false will unmute this CoreWebView2. true if audio is muted. IsDocumentPlayingAudioChanged is raised when document starts or stops playing audio. IsMutedChanged is raised when the mute state changes. The default download dialog corner alignment. The default download dialog margin relative to the WebView corner specified by . The margin is a point that describes the vertical and horizontal distances between the chosen WebView corner and the default download dialog corner nearest to it. Positive values move the dialog towards the center of the WebView from the chosen WebView corner, and negative values move the dialog away from it. Use (0, 0) to align the dialog to the WebView corner with no margin. The corner alignment and margin should be set during initialization to ensure that they are correctly applied when the layout is first computed, otherwise they will not take effect until the next time the WebView position or size is updated. True if the default download dialog is currently open. The value of this property changes only when the default download dialog is explicitly opened or closed. Hiding the WebView implicitly hides the dialog, but does not change the value of this property. Raised when the property changes. This event comes after the event. Setting the property disables the default download dialog and ensures that this event is never raised. Open the default download dialog. If the dialog is opened before there are recent downloads, the dialog shows all past downloads for the current profile. Otherwise, the dialog shows only the recent downloads with a "See more" button for past downloads. Calling this method raises the event if the dialog was closed. No effect if the dialog is already open. Close the default download dialog. Calling this method raises the event if the dialog was open. No effect if the dialog is already closed. Creates a CoreWebView2 object that wraps an existing COM ICoreWebView2 object. This allows interacting with the CoreWebView2 using .NET, even if it was originally created using COM. Pointer to a COM object that implements the ICoreWebView2 COM interface. Returns a .NET CoreWebView2 object that wraps the COM object. Thrown when the provided COM pointer is null. Thrown when the value is not an ICoreWebView2 COM object and cannot be wrapped. Returns the existing COM ICoreWebView2 object underlying this .NET CoreWebView2 object. This allows interacting with the WebView2 control using COM APIs, even if the control was originally created using .NET. Pointer to a COM object that implements the ICoreWebView2 COM interface. Same as , but also has support for posting DOM objects to page content. The web message to be posted to the top level document in this WebView. Additional DOM objects posted to the content. The event args is an instance of MessageEvent. The setting must be true or the message will not be sent. The event arg's data property of the event arg is the webMessageAsJson string parameter parsed as a JSON string into a JavaScript object. The event arg's source property of the event arg is a reference to the window.chrome.webview object. For information about sending messages from the HTML document in the WebView to the host, navigate to . The message is sent asynchronously. If a navigation occurs before the message is posted to the page, the message is not be sent. This additionalObjects is retrieved in web content via the DOM MessageEvent additionalObjects property as an array-like list of DOM objects. Currently these type of objects can be posted: .NET / WinRT DOM type [FileSystemHandle](https://developer.mozilla.org/docs/Web/API/FileSystemHandle) null null The objects are posted to web content, following the [structured-clone](https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) semantics, meaning only objects that can be cloned can be posted. They will also behave as if they had been created by the web content they are posted to. For example, if a FileSystemFileHandle is posted to a web content it can only be re-transferred via postMessage to other web content [with the same origin](https://fs.spec.whatwg.org/#filesystemhandle). Warning: An app needs to be mindful when using this API to post DOM objects as this API provides the web content with unusual access to sensitive Web Platform features such as filesystem access! Similar to PostWebMessageAsJson, the app should check the property right before posting the message to ensure the message and objects will only be sent to the target web content that it expects to receive the DOM objects. Additionally, the order of messages that are posted between PostWebMessageAsJson and PostWebMessageAsJsonWithAdditionalObjects may not be preserved. Opens the browser print preview dialog to print the current web page Event args for the event. Indicates whether the event is handled by host. If set to true then this prevents the WebView from performing the default action for this accelerator key. Otherwise the WebView will perform the default action for the accelerator key. Gets the key event kind that caused the event to run. Gets the LPARAM value that accompanied the window message. See the documentation for the WM_KEYDOWN and WM_KEYUP messages. Gets a representing the information passed in the LPARAM of the window message. Gets the Win32 virtual key code of the key that was pressed or released. It is one of the Win32 virtual key constants such as VK_RETURN or an (uppercase) ASCII value such as 'A'. Verify whether Ctrl or Alt are pressed by running GetKeyState(VK_CONTROL) or GetKeyState(VK_MENU). This `IsBrowserAcceleratorKeyEnabled` property allows developers to control whether the browser handles accelerator keys such as Ctrl+P or F3, etc. The `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` API is a convenient setting for developers to disable all the browser accelerator keys together. This setting also sets the default value for the `IsBrowserAcceleratorKeyEnabled` property. By default, `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` is `TRUE` and `IsBrowserAcceleratorKeyEnabled` is `TRUE`. When developers change `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting to `FALSE`, this will change default value for `IsBrowserAcceleratorKeyEnabled` to `FALSE`. If developers want specific keys to be handled by the browser after changing the `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting to `FALSE`, they need to enable these keys by setting `IsBrowserAcceleratorKeyEnabled` to `TRUE`. The `CoreWebView2Controller.AcceleratorKeyPressed` event is raised any time an accelerator key is pressed, regardless of whether accelerator keys are enabled or not. This API will give the event arg higher priority over the `CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled` setting when we handle the keys. With `IsBrowserAcceleratorKeyEnabled` property, if developers mark `IsBrowserAcceleratorKeyEnabled` as `FALSE`, the browser will skip the WebView2 browser feature accelerator key handling process, but the event propagation continues, and web content will receive the key combination. This property does not disable accelerator keys related to movement and text editing, such as: - Home, End, Page Up, and Page Down - Ctrl-X, Ctrl-C, Ctrl-V - Ctrl-A for Select All - Ctrl-Z for Undo Event args for the BasicAuthenticationRequested event. Will contain the request that led to the HTTP authorization challenge, the challenge and allows the host to provide authentication response or cancel the request. Indicates whether to cancel the authentication request. false by default. If set to true, Response will be ignored. The authentication challenge string. Response to the authentication request with credentials. This object will be populated by the app if the host would like to provide authentication credentials. The URI that led to the authentication challenge. For proxy authentication requests, this will be the URI of the proxy server. Gets a Deferral object. Use this Deferral to defer the decision to show the Basic Authentication dialog. Represents a Basic HTTP authentication response that contains a user name and a password as according to RFC7617 (https://tools.ietf.org/html/rfc7617). Password provided for authentication. User name provided for authentication. Browser extension installed on current profile. This is the browser extension's ID. This is the same browser extension ID returned by the browser extension API [chrome.runtime.id](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/id). Please see that documentation for more details on how the ID is generated. After an extension is removed, calling Id will return the id of the extension that is removed. If IsEnabled is true then the Extension is enabled and running in WebView instances. If it is false then the Extension is disabled and not running in WebView instances. When a Extension is first installed, IsEnable are default to be true. IsEnabled is persisted per profile. After an extension is removed, calling IsEnabled will return the value at the time it was removed. This is the browser extension's name. This value is defined in this browser extension's manifest.json file. If manifest.json define extension's localized name, this value will be the localized version of the name. Please see [Manifest.json name](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/manifest.json/name) for more details. Removes this browser extension from its WebView2 Profile. The browser extension is removed immediately including from all currently running HTML documents associated with this WebView2 Profile. The removal is persisted and future uses of this profile will not have this extension installed. After an extension is removed, calling Remove again will cause an exception. Sets whether this browser extension is enabled or disabled. This change applies immediately to the extension in all HTML documents in all WebView2s associated with this profile. After an extension is removed, calling Enable will not change the value of IsEnabled. Event args for the event. The kind of browser process exit that has occurred. The process ID of the browser process that has exited. Represents a certificate and provides access to its metadata. Base64 encoding of DER encoded serial number of the certificate. Read more about DER at [RFC 7468 DER](https://tools.ietf.org/html/rfc7468#appendix-B). Display name for a certificate. Name of the certificate authority that issued the certificate. Returns list of PEM encoded certificate issuer chain. In this list first element is the current certificate followed by intermediate1, intermediate2...intermediateN-1. Root certificate is the last element in the list. Subject of the certificate. PEM encoded data for the certificate. Returns Base64 encoding of DER encoded certificate. Read more about PEM at [RFC 1421 Privacy Enhanced Mail](https://tools.ietf.org/html/rfc1421). Converts this to a X509Certificate2. An object created using PEM encoded data from this object. The valid date and time for the certificate since the UNIX epoc. The valid date and time for the certificate since the UNIX epoc. Represents a client certificate that provides access to the client certificate metadata. Base64 encoding of DER encoded serial number of the certificate. Read more about DER at [RFC 7468 DER](https://tools.ietf.org/html/rfc7468#appendix-B). Display name for a certificate. Name of the certificate authority that issued the certificate. Kind of a certificate. See for descriptions. Returns list of PEM encoded client certificate issuer chain. In this list first element is the current certificate followed by intermediate1, intermediate2...intermediateN-1. Root certificate is the last element in the list. Subject of the certificate. PEM encoded data for the certificate. Returns Base64 encoding of DER encoded certificate. Read more about PEM at [RFC 1421 Privacy Enhanced Mail](https://tools.ietf.org/html/rfc1421). Converts this to a X509Certificate2. An object created using PEM encoded data from this object. The valid date and time for the certificate since the UNIX epoc. The valid date and time for the certificate since the UNIX epoc. Event args for the event. The list contains Base64 encoding of DER encoded distinguished names of certificate authorities allowed by the server. Indicates whether to cancel the certificate selection. If canceled, the request is aborted regardless of the property. By default the value is false. Indicates whether the event has been handled by host. Set to true to respond to the server with or without a certificate. If this flag is true with a it responds to the server with the selected certificate otherwise respond to the server without a certificate. By default the value of and are false and display default client certificate selection dialog prompt to allow the user to choose a certificate. The is ignored unless is set to true. Host name of the server that requested client certificate authentication. Normalization rules applied to the hostname are: Convert to lowercase characters for ascii characters.Punycode is used for representing non ascii characters.Strip square brackets for IPV6 address. Returns true if the server that issued this request is an http proxy. Returns false if the server is the origin server. Returns the list of when client certificate authentication is requested. The list contains mutually trusted CA certificate. Port of the server that requested client certificate authentication. Selected certificate to respond to the server. Gets a Deferral object. Use this to Complete the event at a later time. This class is an extension of the class to support visual hosting. Gets the current cursor that WebView thinks it should be. The cursor should be set in WM_SETCURSOR through Mouse.SetCursor or set on the corresponding parent/ancestor HWND of the WebView through ::SetClassLongPtr. The HCURSOR can be freed so CopyCursor/DestroyCursor is recommended to keep your own copy if you are doing more than immediately setting the cursor. Gets or sets the root visual in the hosting app's visual tree. This visual is where the WebView will connect its visual tree. The app uses this visual to position the WebView within the app. The app still needs to use the property to size the WebView. The RootVisualTarget property can be an IDCompositionVisual or a Windows::UI::Composition::ContainerVisual. WebView will connect its visual tree to the provided visual before returning from the property setter. The app needs to commit on its device setting the RootVisualTarget property. The RootVisualTarget property supports being set to null to disconnect the WebView from the app's visual tree. Gets the current system cursor ID reported by the underlying rendering engine for WebView. The event is raised when WebView thinks the cursor should be changed. For example, when the mouse cursor is currently the default cursor but is then moved over text, it may try to change to the IBeam cursor. It is expected for the developer to send messages (in addition to messages) through . This is to ensure that the mouse is actually within the WebView that sends out CursorChanged events. The mouse event kind.The virtual keys associated with the eventKind.The amount of wheel movement.The absolute position of the mouse, or the amount of motion since the last mouse event was generated, depending on the eventKind. Sends mouse input to the WebView. If eventKind is or , then mouseData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120. If eventKind is , , or , then mouseData specifies which X buttons were pressed or released. This value should be 1 if the first X button is pressed/released and 2 if the second X button is pressed/released. If eventKind is , then virtualKeys, mouseData, and point should all be zero. If eventKind is any other value, then mouseData should be zero. point is expected to be in the client coordinate space of the WebView. To track mouse events that start in the WebView and can potentially move outside of the WebView and host application, calling SetCapture and ReleaseCapture is recommended. To dismiss hover popups, it is also recommended to send messages. Sends pen or pointer input to the WebView. The pointer event kind.The pointer information. Accepts touch or pen pointer input of kinds defined in . Any pointer input from the system must be converted into a first. Call this method to inform the CoreWebView2CompositionController that a drag operation has left the WebView. Corresponds to the [ICoreDropOperationTarget.LeaveAsync](/uwp/api/windows.applicationmodel.datatransfer.dragdrop.core.icoredropoperationtarget.leaveasync) method when performing a drag operation into the WebView. This event is raised when elements on the page with "app-region" CSS property values corresponding to non-client regions change. Use the to see the kind of non-client region that changed. Call this method to perform hit-testing inside of your message loop when the message is WM_NCHITTEST. The point parameter is expected to be in the client coordinate space of the WebView2.The type of region which contains the point. When a given region kind of type This method returns a vector of rectangles which corresponds to the specified region. This method can be used inside the event handler to get the list of rects for the specific region that changed. Event args for the event. true if the loaded content is an error page. The ID of the navigation. Represents a context menu item of a context menu displayed by WebView. Gets the list of children menu items if the kind is . If the kind is not , will return null. Gets the Command ID for the . Use this to report the in event. Gets the Icon for the in PNG, Bitmap or SVG formats in the form of an IStream. Stream will be rewound to the start of the image data before being read. Gets or sets the checked property of the . Must only be used for custom context menu items that are of kind CoreWebView2ContextMenuItemKind.CheckBox or CoreWebView2ContextMenuItemKind.Radio. Gets or sets the enabled property of the . Must only be used in the case of a custom context menu item. The default value for this is true. Gets the kind of as . Gets the localized label for the . Will contain an ampersand for characters to be used as keyboard accelerator. Gets the unlocalized name for the . Use this to distinguish between context menu item types. This will be the English label of the menu item in lower camel case. For example, the "Save as" menu item will be "saveAs". Extension menu items will be "extension", custom menu items will be "custom" and spellcheck items will be "spellCheck". Some example context menu item names are: "saveAs" "copyImage" "openLinkInNewWindow" Gets the localized keyboard shortcut for this . It will be the empty string if there is no keyboard shortcut. This is text intended to be displayed to the end user to show the keyboard shortcut. For example this property is Ctrl+Shift+I for the "Inspect" . CustomItemSelected event is raised when the user selects this . Will only be raised for end developer created context menu items. Event args for the event. Will contain the selection information and a collection of all of the default context menu items that the WebView would show. Allows the app to draw its own context menu or add/remove from the default context menu. Gets the target information associated with the requested context menu. Gets or sets whether the event is handled by host after the event handler completes or after the deferral is completed if there is a taken Deferral. If Handled is set to true then WebView2 will not display a context menu and will instead use the property to indicate which, if any, context menu item to invoke. If after the event handler or deferral completes, Handled is set to false then WebView will display a context menu based on the contents of the property. The default value is false. Gets the coordinates where the context menu request occurred in relation to the upper left corner of the WebView bounds. Gets the collection of objects. Gets or sets the selected 's . When the app handles the event, it can set this to report the selected command from the context menu. The default value is -1 which means that no selection occurred. The app can also set the command ID for a custom context menu item, which will cause the event to be fired, however while command IDs for each custom context menu item is unique during a ContextMenuRequested event, WebView may reassign command ID values of deleted custom ContextMenuItems to new objects and the command ID assigned to the same custom item can be different between each app runtime. The command ID should always be obtained via the property. Returns a Deferral object. Use this operation to complete the event when the custom context menu is closed. Represents the information regarding the context menu target. Includes the context selected and the appropriate data used for the actions of a context menu. Gets the uri of the frame. Will match the if is true. Returns true if the context menu is requested on text element that contains an anchor tag. Returns true if the context menu is requested on HTML containing an anchor tag. Returns true if the context menu is requested on a selection. Returns true if the context menu is requested on HTML containing a source uri. Returns true if the context menu is requested on an editable component. Returns true if the context menu was requested on the main frame and false if invoked on another frame. Gets the kind of context that the user selected as . Gets the text of the link (if is true, null otherwise). Gets the uri of the link (if is true, null otherwise). Gets the uri of the page. Gets the selected text (if is true, null otherwise). Gets the active source uri of element (if is true, null otherwise). The owner of the object that provides support for resizing, showing and hiding, focusing, and other functionality related to windowing and composition. The CoreWebView2Controller owns the , and if all references to the go away, the WebView is closed. This class is the owner of the object, and provides support for resizing, showing and hiding, focusing, and other functionality related to windowing and composition. The owns the , and if all references to the go away, the WebView will be closed. Gets or sets the WebView bounds. Bounds are relative to the . The app has two ways to position a WebView: Create a child HWND that is the WebView parent HWND. Position the window where the WebView should be. Use (0, 0) for the top-left corner (the offset) of the Bounds of the WebView. Use the top-most window of the app as the WebView parent HWND. For example, to position ebView correctly in the app, set the top-left corner of the Bounds of the WebView. The values of Bounds are limited by the coordinate space of the host. Determines whether to show or hide the WebView. If `IsVisible` is set to `false`, the WebView is transparent and is not rendered. However, this does not affect the window containing the WebView (the `ParentWindow` parameter that was passed to ). WebView as a child window does not get window messages when the top window is minimized or restored. For performance reasons, developers should set the IsVisible property of the WebView to false when the app window is minimized and back to true when the app window is restored. The app window does this by handling SIZE_MINIMIZED and SIZE_RESTORED command upon receiving WM_SIZE message. There are CPU and memory benefits when the page is hidden. For instance Chromium has code that throttles activities on the page like animations and some tasks are run less frequently. Similarly, WebView2 will purge some caches to reduce memory usage. Gets the parent window provided by the app or sets the parent window that this WebView is using to render content. It initially returns the `ParentWindow` passed into . Setting the property causes the WebView to re-parent the main WebView window to the newly provided window. Gets or sets the zoom factor for the WebView. Note that changing zoom factor may cause window.innerWidth or window.innerHeight and page layout to change. A zoom factor that is applied by the host by setting this ZoomFactor property becomes the new default zoom for the WebView. This zoom factor applies across navigations and is the zoom factor WebView is returned to when the user presses Ctrl+0. When the zoom factor is changed by the user (resulting in the app receiving ), that zoom applies only for the current page. Any user applied zoom is only for the current page and is reset on a navigation. Specifying a ZoomFactor less than or equal to 0 is not allowed. WebView also has an internal supported zoom factor range. When a specified zoom factor is out of that range, it is normalized to be within the range, and a event is raised for the real applied zoom factor. When this range normalization happens, this reports the zoom factor specified during the previous modification of the ZoomFactor property until the event is received after WebView applies the normalized zoom factor. AcceleratorKeyPressed is raised when an accelerator key or key combo is pressed or released while the WebView is focused. A key is considered an accelerator if either of the following conditions are true: Ctrl or Alt is currently being held. The pressed key does not map to a character. A few specific keys are never considered accelerators, such as Shift. The Escape key is always considered an accelerator. Autorepeated key events caused by holding the key down will also raise this event. Filter out the auto-repeated key events by verifying or . In windowed mode, this event is synchronous. Until you set to true or the event handler returns, the browser process is blocked and outgoing cross-process COM calls will fail with RPC_E_CANTCALLOUT_ININPUTSYNCCALL. All methods work, however. In windowless mode, the event is asynchronous. Further input do not reach the browser until the event handler returns or is set to true, but the browser process is not blocked, and outgoing COM calls work normally. It is recommended to set to true as early as you are able to know that you want to handle the accelerator key. GotFocus is raised when WebView gets focus. LostFocus is raised when WebView loses focus. In the case where event is raised, the focus is still on WebView when event is raised. LostFocus is only raised afterwards when code of the app or default action of event sets focus away from WebView. MoveFocusRequested is raised when user tries to tab out of the WebView. The focus of the WebView has not changed when this event is raised. ZoomFactorChanged is raised when the property changes. The event may be raised because the property was modified, or due to the user manually modifying the zoom. When it is modified using the property, the internal zoom factor is updated immediately and no ZoomFactorChanged event is raised. WebView associates the last used zoom factor for each site. It is possible for the zoom factor to change when navigating to a different page. When the zoom factor changes due to a navigation change, the ZoomFactorChanged event is raised right after the event. Updates and properties at the same time. The bounds to be updated.The zoom factor to be updated. This operation is atomic from the perspective of the host. After returning from this function, the and properties are both updated if the function is successful, or neither is updated if the function fails. If and are both updated by the same scale (for example, and are both doubled), then the page does not display a change in window.innerWidth or window.innerHeight and the WebView renders the content at the new size and zoom without intermediate renderings. This function also updates just one of or by passing in the new value for one and the current value for the other. Moves focus into WebView. The reason for moving focus. WebView will get focus and focus will be set to correspondent element in the page hosted in the WebView. For reason, focus is set to previously focused element or the default element if no previously focused element exists. For reason, focus is set to the first element. For reason, focus is set to the last element. WebView changes focus through user interaction including selecting into a WebView or Tab into it. For tabbing, the app runs MoveFocus with or to align with Tab and Shift+Tab respectively when it decides the WebView is the next tabbable element. Tells WebView that the main WebView parent (or any ancestor) HWND moved. This is a notification separate from . This is needed for accessibility and certain dialogs in WebView to work correctly. Closes the WebView and cleans up the underlying browser instance. Cleaning up the browser instance releases the resources powering the WebView. The browser instance is shut down if no other WebViews are using it. After running Close, all methods fail and event handlers stop running. Specifically, the WebView releases the associated references to any associated event handlers when Close is run. Close is implicitly run when the loses the final reference and is destructed. But it is best practice to explicitly run Close to avoid any accidental cycle of references between the WebView and the app code. Specifically, if you capture a reference to the WebView in an event handler you create a reference cycle between the WebView and the event handler. Run Close to break the cycle by releasing all event handlers. But to avoid the situation, it is best to both explicitly run Close on the WebView and to not capture a reference to the WebView to ensure the WebView is cleaned up correctly. Close is synchronous and won't trigger the beforeunload event. Gets or sets the WebView default background color. The `DefaultBackgroundColor` is the color that renders underneath all web content. This means WebView renders this color when there is no web content loaded such as before the initial navigation or between navigations. This also means web pages with undefined css background properties or background properties containing transparent pixels will render their contents over this color. Web pages with defined and opaque background properties that span the page will obscure the `DefaultBackgroundColor` and display normally. The default value for this property is white to resemble the native browser experience. Currently this API only supports opaque colors and transparency. It will fail for colors with alpha values that don't equal 0 or 255 ie. translucent colors are not supported. It also does not support transparency on Windows 7. On Windows 7, setting DefaultBackgroundColor to a Color with an Alpha value other than 255 will result in failure. On any OS above Win7, choosing a transparent color will result in showing hosting app content. This means webpages without explicit background properties defined will render web content over hosting app content. This property may also be set via the `WEBVIEW2_DEFAULT_BACKGROUND_COLOR` environment variable. There is a known issue with background color where just setting the color by property can still leave the app with a white flicker before the `DefaultBackgroundColor` property takes effect. Setting the color via environment variable solves this issue. The value must be a hex value that can optionally prepend a 0x. The value must account for the alpha value which is represented by the first 2 digits. So any hex value fewer than 8 digits will assume a prepended 00 to the hex value and result in a transparent color. `DefaultBackgroundColor` will return the result of this environment variable even if it has not been set directly. This environment variable can only set the `DefaultBackgroundColor` once. Subsequent updates to background color must be done by setting the property. Gets or sets the WebView bounds mode. BoundsMode affects how setting the and properties work. Bounds mode can either be in mode or mode. Gets or sets the WebView rasterization scale. The rasterization scale is the combination of the monitor DPI scale and text scaling set by the user. This value should be updated when the DPI scale of the app's top level window changes (i.e. monitor DPI scale changes or the window changes monitor) or when the text scale factor of the system changes. Rasterization scale applies to the WebView content, as well as popups, context menus, scroll bars, and so on. Normal app scaling scenarios should use the property or method. Determines whether the WebView will detect monitor scale changes. ShouldDetectMonitorScaleChanges property determines whether the WebView attempts to track monitor DPI scale changes. When true, the WebView will track monitor DPI scale changes, update the property, and fire event. When false, the WebView will not track monitor DPI scale changes, and the app must update the property itself. event will never raise when ShouldDetectMonitorScaleChanges is false. Apps that want to set their own rasterization scale should set this property to false to avoid the WebView2 updating the property to match the monitor DPI scale. RasterizationScaleChanged is raised when the property changes. The event is raised when the Webview detects that the monitor DPI scale has changed, is true, and the Webview has changed the property. Gets or sets the WebView allow external drop property. The AllowExternalDrop is to configure the capability that dropping files into webview2 is allowed or permitted. The default value is true. Gets the associated with this . Used to manage profile options that created by . Manage the controller's InPrivate mode. Manage the name of the controller's profile. The ProfileName property is to specify a profile name, which is only allowed to contain the following ASCII characters. It has a maximum length of 64 characters excluding the null-terminator. It is ASCII case insensitive. * alphabet characters: a-z and A-Z * digit characters: 0-9 * and '#', '@', '$', '(', ')', '+', '-', '_', '~', '.', ' ' (space). Note: the text must not end with a period '.' or ' ' (space). And, although upper-case letters are allowed, they're treated just as lower-case counterparts because the profile name will be mapped to the real profile directory path on disk and Windows file system handles path names in a case-insensitive way. This property allows users to initialize the `DefaultBackgroundColor` early, preventing a white flash that can occur while WebView2 is loading when the background color is set to something other than white. With early initialization, the color remains consistent from the start. After initialization, `CoreWebView2Controller.DefaultBackgroundColor` will return the value set using this API. The `CoreWebView2Controller.DefaultBackgroundColor` can be set via the WEBVIEW2_DEFAULT_BACKGROUND_COLOR environment variable, which will remain supported for cases where this solution is being used. It is encouraged to transition away from the environment variable and use this API solution to apply the property. It is important to highlight that when set, the enviroment variable overrides ControllerOptions::DefaultBackgroundColor and becomes the initial value of Controller::DefaultBackgroundColor. The `DefaultBackgroundColor` is the color that renders underneath all web content. This means WebView2 renders this color when there is no web content loaded. When no background color is defined in WebView2, it uses the `DefaultBackgroundColor` property to render the background. By default, this color is set to white. This API only supports opaque colors and full transparency. It will fail for colors with alpha values that don't equal 0 or 255. When WebView2 is set to be fully transparent, it does not render a background, allowing the content from windows behind it to be visible. `AllowHostInputProcessing` property is to enable/disable input passing through the app before being delivered to the WebView2. This property is only applicable to controllers created with `CoreWebView2Environment.CreateCoreWebView2ControllerAsync` and not composition controllers created with `CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync`. By default the value is `FALSE`. Setting this property has no effect when using visual hosting. \snippet AppWindow.cpp AllowHostInputProcessing Manages the value of the controller's script locale. The ScriptLocale property is to specify the default script locale. It sets the default locale for all Intl JavaScript APIs and other JavaScript APIs that depend on it, namely Intl.DateTimeFormat() which affects string formatting like in the time/date formats.The intended locale value is in the format of BCP 47 Language Tags. More information can be found from [IETF BCP47](https://www.ietf.org/rfc/bcp/bcp47.html ). The default value for ScriptLocale will be depend on the WebView2 language and OS region. If the language portions of the WebView2 language and OS region match, then it will use the OS region. Otherwise, it will use the WebView2 language. OS Region WebView2 Language Default WebView2 ScriptLocale en-GB en-US en-GB es-MX en-US en-US en-US en-GB en-US You can set the ScriptLocale to the empty string to get the default ScriptLocale value. Use OS specific APIs to determine the OS region to use with this property if you always want to match with the OS region. For example: CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; return cultureInfo.Name Provides a set of properties that are used to manage a . Gets the domain for which the cookie is valid. The default value is the host that this cookie has been received from. Note that, for instance, .bing.com, bing.com, and www.bing.com are considered different domains. Determines whether this cookie is http-only. Gets or sets the security level of this cookie. Determines whether this is a session cookie. The default value is false. Get or sets the cookie name. Gets the path for which the cookie is valid. The default value is "/", which means this cookie will be sent to all pages on the . Determines the SameSite status of the cookie which represents the enforcement mode of the cookie. The default value is CoreWebView2CookieSameSiteKind.Lax. Gets or sets the cookie value. Converts this to a System.Net.Cookie. An object whose , , , , , , and , matches those , , , , , , and of this object. The values of the properties other than those specified above remain their default values. The expiration date and time for the cookie since the UNIX epoch. Setting the Expires property to makes this a session cookie, which is its default value. Creates, adds or updates, gets, or or view the cookies. The changes would apply to the context of the user profile. That is, other WebViews under the same user profile could be affected. Creates a cookie object with a specified name, value, domain, and path. One can set other optional properties after cookie creation. This only creates a cookie object and it is not added to the cookie manager until you call . name that starts with whitespace(s) is not allowed. The name for the to be created. It cannot start with whitespace(s). Creates a cookie whose params matches those of the specified cookie. Gets a list of cookies matching the specific URI. You can modify the cookie objects by calling , and the changes will be applied to the webview. If uri is empty string or null, all cookies under the same profile are returned. Adds or updates a cookie with the given cookie data; may overwrite cookies with matching name, domain, and path if they exist. The to be added or updated. This method will fail if the domain of the given cookie is not specified. Deletes a cookie whose name and domain/path pair match those of the specified cookie. Deletes cookies with matching name and uri. The name for the cookies to be deleted is required.If uri is specified, deletes all cookies with the given name where domain and path match provided URI. Deletes cookies with matching name and domain/path pair. The name for the cookies to be deleted is required.If domain is specified, deletes only cookies with the exact domain.If path is specified, deletes only cookies with the exact path. Deletes all cookies under the same profile. This could affect other WebViews under the same user profile. Creates a CoreWebView2Cookie object whose params matches those of the given System.Net.Cookie. A System.Net.Cookie whose params to be used to create a CoreWebView2Cookie. An object whose , , , , , , and , matches those , , , , , , and of the given object. The default value for the property of the returned object is . Represents the registration of a custom scheme with the . This allows the WebView2 app to be able to handle event for requests with the specified scheme and be able to navigate the WebView2 to the custom scheme. Once the environment is created, the registrations are valid and immutable throughout the lifetime of the associated WebView2s' browser process and any WebView2 environments sharing the browser process must be created with identical custom scheme registrations, otherwise the environment creation will fail. Any further attempts to register the same scheme will fail during environment creation. The URIs of registered custom schemes will be treated similar to http URIs for their origins. They will have tuple origins for URIs with host and opaque origins for URIs without host as specified in [7.5 Origin - HTML Living Standard](https://html.spec.whatwg.org/multipage/origin.html). Example: `custom-scheme-with-host://hostname/path/to/resource` has origin of `custom-scheme-with-host://hostname`. `custom-scheme-without-host:path/to/resource` has origin of `custom-scheme-without-host:path/to/resource`. For event, the cases of request URIs and filter URIs with custom schemes will be normalized according to generic URI syntax rules. Any non-ASCII characters will be preserved. The registered custom schemes also participate in [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) and adheres to [CSP](https://developer.mozilla.org/docs/Web/HTTP/CSP). The app needs to set the appropriate access headers in its event handler to allow CORS requests. Represents the registration of a custom scheme with the . This allows the WebView2 app to be able to handle event for requests with the specified scheme and be able to navigate the WebView2 to the custom scheme. Once the environment is created, the registrations are valid and immutable throughout the lifetime of the associated WebView2s' browser process and any WebView2 environments sharing the browser process must be created with identical custom scheme registrations, otherwise the environment creation will fail. Any further attempts to register the same scheme will fail during environment creation. The URIs of registered custom schemes will be treated similar to http URIs for their origins. They will have tuple origins for URIs with host and opaque origins for URIs without host as specified in [7.5 Origin - HTML Living Standard](https://html.spec.whatwg.org/multipage/origin.html) For event, the cases of request URIs and filter URIs with custom schemes will be normalized according to generic URI syntax rules. Any non-ASCII characters will be preserved. The registered custom schemes also participate in [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) and adheres to [CSP](https://developer.mozilla.org/docs/Web/HTTP/CSP). The app needs to set the appropriate access headers in its event handler to allow CORS requests. custom-scheme-with-host://hostname/path/to/resource has origin of custom-scheme-with-host://hostname. custom-scheme-without-host:path/to/resource has origin of custom-scheme-without-host:path/to/resource. The name of the custom scheme to register. Whether the sites with this scheme will be treated as a [Secure Context](https://developer.mozilla.org/docs/Web/Security/Secure_Contexts) like an HTTPS site. Set this property to true if the URIs with this custom scheme will have an authority component (a host for custom schemes). Specifically, if you have a URI of the following form you should set the HasAuthorityComponent value as listed. URI Recommended HasAuthorityComponent value custom-scheme-with-authority://host/path true custom-scheme-without-authority:path false When this property is set to true, the URIs with this scheme will be interpreted as having a [scheme and host](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-tuple) origin similar to an http URI. Note that the port and user information are never included in the computation of origins for custom schemes. If this property is set to false, URIs with this scheme will have an [opaque origin](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque) similar to a data URI. This property is false by default. Note: For custom schemes registered as having authority component, navigations to URIs without authority of such custom schemes will fail. However, if the content inside WebView2 references a subresource with a URI that does not have an authority component, but of a custom scheme that is registered as having authority component, the URI will be interpreted as a relative path as specified in [RFC3986](https://www.rfc-editor.org/rfc/rfc3986). For example, custom-scheme-with-authority:path will be interpreted as custom-scheme-with-authority://host/path. However, this behavior cannot be guaranteed to remain in future releases so it is recommended not to rely on this behavior. List of origins that are allowed to issue requests with the custom scheme, such as XHRs and subresource requests that have an Origin header. The origin of any request (requests that have the [Origin header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Origin)) to the custom scheme URI needs to be in this list. No-origin requests are requests that do not have an Origin header, such as link navigations, embedded images and are always allowed. Note that cross-origin restrictions still apply. From any opaque origin (Origin header is null), no cross-origin requests are allowed. If the list is empty, no cross-origin request to this scheme is allowed. Origins are specified as a string in the format of scheme://host:port. The origins are string pattern matched with * (matches 0 or more characters) and ? (matches 0 or 1 character) wildcards just like the URI matching in the API. For example, http://*.example.com:80. Here's a set of examples of what is allowed or not: Request URI Originating URL AllowedOrigins Allowed custom-scheme:request https://www.example.com {"https://www.example.com"} Yes custom-scheme:request https://www.example.com {"https://*.example.com"} Yes custom-scheme:request https://www.example.com {"https://www.example2.com"} No custom-scheme-with-authority://host/path custom-scheme-with-authority://host2 {""} No custom-scheme-with-authority://host/path custom-scheme-with-authority2://host {"custom-scheme-with-authority2://*"} Yes custom-scheme-without-authority:path custom-scheme-without-authority:path2 {"custom-scheme-without-authority:*"} No custom-scheme-without-authority:path custom-scheme-without-authority:path2 {"*"} Yes Initializes a new instance of the CoreWebView2CustomSchemeRegistration class. The name of the custom scheme to register. Event args for the event. The ID of the navigation which corresponds to other navigation ID properties on other navigation events. This is used to complete deferrals on event args that support getting deferrals using the GetDeferral method. This class implements . This is used to complete deferrals on event args that support getting deferrals using the GetDeferral method. This class implements . Completes the associated deferred event. Complete should only be run once for each deferral taken. Protected implementation of Dispose pattern. Event args for the event. Gets the parameter object of the corresponding DevToolsProtocol event represented as a JSON string. Gets the sessionId of the target where the event originates from. Empty string is returned as sessionId if the event comes from the default session for the top page. A Receiver is created for a particular DevTools Protocol event and allows you to subscribe and unsubscribe from that event. Obtained from the WebView object using . DevToolsProtocolEventReceived is raised when the corresponding DevToolsProtocol event is raised. Represents a download operation. Gives access to a download's metadata and supports a user canceling, pausing, or resuming a download. The number of bytes that have been written to the download file. Returns true if an interrupted download can be resumed. Downloads with the following interrupt reasons may automatically resume without you calling any methods: CoreWebView2DownloadInterruptReason.ServerNoRange, CoreWebView2DownloadInterruptReason.FileHashMismatch, CoreWebView2DownloadInterruptReason.FileTooShort. In these cases progress may be restarted with set to 0. The Content-Disposition header value from the download's HTTP response. If none, the value is an empty string. The reason why connection with file host was broken. See for descriptions of reasons. MIME type of the downloaded content. The absolute path to the download file, including file name. Host can change this from . The state of the download. A download can be in progress, interrupted, or completed. See for descriptions of states. The URI of the download. Event raised when the bytes received count is updated. Event raised when the estimated end time changes. Event raised when the state of the download changes. Use CoreWebView2DownloadOperation.State to get the current state, and CoreWebView2DownloadOperation.InterruptReason to get the reason if the download is interrupted. Cancels the download. If canceled, the default download dialog shows that the download was canceled. Host should use if download should be canceled without displaying the default download dialog. Pauses the download. If paused, the default download dialog shows that the download is paused. No effect if download is already paused. Pausing a download changes the state from in progress to interrupted, with interrupt reason set to CoreWebView2DownloadInterruptReason.UserCanceled. Resumes a paused download. May also resume a download that was interrupted for another reason if returns true. Resuming a download changes the state from interrupted to in progress. The estimated end time of the download. The total bytes to receive count. Event args for the event. Indicates whether to cancel the download. If canceled, the download save dialog is not displayed regardless of the value and the state is changed to CoreWebView2DownloadState.Interrupted with interrupt reason CoreWebView2DownloadInterruptReason.UserCanceled. Returns the for the download that has started. Indicates whether to hide the default download dialog. If set to true, the default download dialog is hidden for this download. The download progresses normally if it is not canceled, there will just be no default UI shown. By default the value is false and the default download dialog is shown. The path to the file. If setting the path, the host should ensure that it is an absolute path, including the file name, and that the path does not point to an existing file. If the path points to an existing file, the file will be overwritten. If the directory does not exist, it is created. Gets a Deferral object. Use this to Complete the event at a later time. This represents the WebView2 Environment. WebViews created from an environment run on the Browser process specified with environment parameters and objects created from an environment should be used in the same environment. Using it in different environments are not guaranteed to be compatible and may fail. This represents the WebView2 Environment. WebViews created from an environment run on the Browser process specified with environment parameters and objects created from an environment should be used in the same environment. Using it in different environments are not guaranteed to be compatible and may fail. Gets the browser version info of the current , including channel name if it is not the stable channel. It matches the format of the method. Channel names are beta, dev, and canary. NewBrowserVersionAvailable is raised when a newer version of the WebView2 Runtime is installed and available using WebView2. To use the newer version of the browser you must create a new environment and WebView. The event is only raised for new version from the same WebView2 Runtime from which the code is running. When not running with installed WebView2 Runtime, no event is raised. Because a user data folder is only able to be used by one browser process at a time, if you want to use the same user data folder in the WebViews using the new version of the browser, you must close the environment and instance of WebView that are using the older version of the browser first. Or simply prompt the user to restart the app. Asynchronously creates a new WebView. The HWND in which the WebView should be displayed and from which receive input. The WebView adds a child window to the provided window during WebView creation. Z-order and other things impacted by sibling window order are affected accordingly. HWND_MESSAGE is a valid parameter for ParentWindow for an invisible WebView for Windows 8 and above. In this case the window will never become visible. You are not able to reparent the window after you have created the WebView. This is not supported in Windows 7 or below. Passing this parameter in Windows 7 or below will return ERROR_INVALID_WINDOW_HANDLE in the controller callback. It can also accept a which is created by as the second parameter for multiple profiles support. As WebView2 is built on top of Edge browser, it follows Edge's behavior pattern. To create an InPrivate WebView, we gets an off-the-record profile (an InPrivate profile) from a regular profile, then create the WebView with the off-the-record profile. Multiple profiles under single user data directory can share some system resources including memory, CPU footprint, disk space (such as compiled shaders and safebrowsing data) etc. It is recommended that the application set Application User Model ID for the process or the application window. If none is set, during WebView creation a generated Application User Model ID is set to root window of ParentWindow. It is recommended that the app handles restart manager messages, to gracefully restart it in the case when the app is using the WebView2 Runtime from a certain installation and that installation is being uninstalled. For example, if a user installs a version of the WebView2 Runtime and opts to use another version of the WebView2 Runtime for testing the app, and then uninstalls the 1st version of the WebView2 Runtime without closing the app, the app restarts to allow un-installation to succeed. When the app retries CreateCoreWebView2ControllerAsync upon failure, it is recommended that the app restarts from creating a new WebView2 Environment. If a WebView2 Runtime update happens, the version associated with a WebView2 Environment may have been removed and causing the object to no longer work. Creating a new WebView2 Environment works since it uses the latest version. WebView creation fails if a running instance using the same user data folder exists, and the Environment objects have different . For example, if a WebView was created with one , an attempt to create a WebView with a different using the same user data folder fails. WebView creation can fail with `E_UNEXPECTED` if runtime does not have permissions to the user data folder. Creates a new object. HTTP response content as stream.The HTTP response status code.The HTTP response reason phrase.The raw response header string delimited by newline. It is also possible to create this object with empty headers string and then use the to construct the headers line by line. Create a new WebView with options. Create a new WebView in visual hosting mode with options. Gets the failure report folder that all CoreWebView2s created from this environment are using. Create a shared memory based buffer with the specified size in bytes. The buffer can be shared with web contents in WebView by calling or . Once shared, the same content of the buffer will be accessible from both the app process and script in WebView. Modification to the content will be visible to all parties that have access to the buffer. The shared buffer is presented to the script as ArrayBuffer. All JavaScript APIs that work for ArrayBuffer including Atomics APIs can be used on it. There is currently a limitation that only size less than 2GB is supported. Returns a snapshot collection of corresponding to all currently running processes associated with this excludes crashpad process. This provides the same list of as what's provided in , but additionally provides a list of associated which are actively running (showing or hiding UI elements) in the renderer process. See for more information. Create a `ICoreWebView2FileSystemHandle` object from a path that represents a Web [FileSystemFileHandle](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle). The `path` is the path pointed by the file and must be a syntactically correct fully qualified path, but it is not checked here whether it currently points to a file. If an invalid path is passed, an E_INVALIDARG will be returned and the object will fail to create. Any other state validation will be done when this handle is accessed from web content and will cause the DOM exceptions described in [FileSystemFileHandle methods](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle#instance_methods) if access operations fail. `Permission` property is used to specify whether the Handle should be created with a Read-only or Read-and-write web permission. For the `permission` value specified here, the DOM [PermissionStatus](https://developer.mozilla.org/docs/Web/API/PermissionStatus) property will be [granted](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state) and the unspecified permission will be [prompt](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state). Therefore, the web content then does not need to call [requestPermission](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission) for the permission that was specified before attempting the permitted operation, but if it does, the promise will immediately be resolved with 'granted' PermissionStatus without firing the WebView2 [PermissionRequested](/microsoft-edge/webview2/reference/win32/icorewebview2permissionrequestedeventargs) event or prompting the user for permission. Otherwise, `requestPermission` will behave as the status of permission is currently `prompt`, which means the `PermissionRequested` event will fire or the user will be prompted. Additionally, the app must have the same OS permissions that have propagated to the [WebView2 browser process](/microsoft-edge/webview2/concepts/process-model) for the path it wishes to give the web content to read/write the file. Specifically, the WebView2 browser process will run in same user, package identity, and app container of the app, but other means such as security context impersonations do not get propagated, so such permissions that the app has, will not be effective in WebView2. Note: An exception to this is, if there is a parent directory handle that has broader permissions in the same page context than specified in here, the handle will automatically inherit the most permissive permission of the parent handle when posted to that page context. i.e. If there is already a `FileSystemDirectoryHandle` to `C:\example` that has write permission on a page, even though a WebFileSystemHandle to file `C:\example\file.txt` is created with `COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY` permission, when posted to that page, write permission will be automatically granted to the created handle. An app needs to be mindful that this object, when posted to the web content, provides it with unusual access to OS file system via the Web FileSystem API! The app should therefore only post objects for paths that it wants to allow access to the web content and it is not recommended that the web content "asks" for this path. The app should also check the source property of the target to ensure that it is sending to the web content of intended origin. Once the object is passed to web content, if the content is attempting a read, the file must be existing and available to read similar to a file chosen by [open file picker](https://developer.mozilla.org/docs/Web/API/Window/showOpenFilePicker), otherwise the read operation will [throw a DOM exception](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile#exceptions). For write operations, the file does not need to exist as `FileSystemFileHandle` will behave as a file path chosen by [save file picker](https://developer.mozilla.org/docs/Web/API/Window/showSaveFilePicker) and will create or overwrite the file, but the parent directory structure pointed by the file must exist and an existing file must be available to write and delete or the write operation will [throw a DOM exception](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable#exceptions). Create a `ICoreWebView2FileSystemHandle` object from a path that represents a Web [FileSystemDirectoryHandle](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle). The `path` is the path pointed by the directory and must be a syntactically correct fully qualified path, but it is not checked here whether it currently points to a directory. Any other state validation will be done when this handle is accessed from web content and will cause DOM exceptions if access operations fail. If an invalid path is passed, an E_INVALIDARG will be returned and the object will fail to create. `Permission` property is used to specify whether the Handle should be created with a Read-only or Read-and-write web permission. For the `permission` value specified here, the Web [PermissionStatus](https://developer.mozilla.org/docs/Web/API/PermissionStatus) will be [granted](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state) and the unspecified permission will be [prompt](https://developer.mozilla.org/docs/Web/API/PermissionStatus/state). Therefore, the web content then does not need to call [requestPermission](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/requestPermission) for the permission that was specified before attempting the permitted operation, but if it does, the promise will immediately be resolved with 'granted' PermissionStatus without firing the WebView2 [PermissionRequested](/microsoft-edge/webview2/reference/win32/icorewebview2permissionrequestedeventargs) event or prompting the user for permission. Otherwise, `requestPermission` will behave as the status of permission is currently `Prompt`, which means the `PermissionRequested` event will fire or the user will be prompted. Additionally, the app must have the same OS permissions that have propagated to the [WebView2 browser process](/microsoft-edge/webview2/concepts/process-model) for the path it wishes to give the web content to make any operations on the directory. Specifically, the WebView2 browser process will run in same user, package identity, and app container of the app, but other means such as security context impersonations do not get propagated, so such permissions that the app has, will not be effective in WebView2. Note: An exception to this is, if there is a parent directory handle that has broader permissions in the same page context than specified in here, the handle will automatically inherit the most permissive permission of the parent handle when posted to that page context. i.e. If there is already a `FileSystemDirectoryHandle` to `C:\example` that has write permission on a page, even though a WebFileSystemHandle to directory `C:\example\directory` is created with `COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY` permission, when posted to that page, write permission will be automatically granted to the created handle. An app needs to be mindful that this object, when posted to the web content, provides it with unusual access to OS file system via the Web FileSystem API! The app should therefore only post objects for paths that it wants to allow access to the web content and it is not recommended that the web content "asks" for this path. The app should also check the source property of the target to ensure that it is sending to the web content of intended origin. Once the object is passed to web content, the path must point to a directory as if it was chosen via [directory picker](https://developer.mozilla.org/docs/Web/API/Window/showDirectoryPicker) otherwise any IO operation done on the `FileSystemDirectoryHandle` will throw a DOM exception. Creates a new object. The request URI.The HTTP request method.The raw request header string delimited by CRLF (optional in last header).uri parameter must be absolute URI. It's also possible to create this object with null headers string and then use the to construct the headers line by line. Asynchronously creates a new WebView for use with visual hosting.The HWND in which the app will connect the visual tree of the WebView.ParentWindow will be the HWND that the app will receive pointer/mouse input meant for the WebView (and will need to use or to forward). If the app moves the WebView visual tree to underneath a different window, then it needs to set to update the new parent HWND of the visual tree. Set property on the created to provide a visual to host the browser's visual tree. It is recommended that the application set Application User Model ID for the process or the application window. If none is set, during WebView creation a generated Application User Model ID is set to root window of ParentWindow. It can also accept a which is created by as the second parameter for multiple profiles support. CreateCoreWebView2CompositionController is supported in the following versions of Windows: Windows 11Windows 10Windows Server 2019Windows Server 2016 Creates an empty . The returned needs to be populated with all of the relevant info before calling . BrowserProcessExited is raised when the collection of WebView2 Runtime processes for the browser process of this terminate due to browser process failure or normal shutdown (for example, when all associated WebViews are closed), after all resources have been released (including the user data folder). Multiple app processes can share a browser process by creating their webviews from a with the same user data folder. When the entire collection of WebView2Runtime processes for the browser process exit, all associated objects receive the BrowserProcessExited event. Multiple processes sharing the same browser process need to coordinate their use of the shared user data folder to avoid race conditions and unnecessary waits. For example, one process should not clear the user data folder at the same time that another process recovers from a crash by recreating its WebView controls; one process should not block waiting for the event if other app processes are using the same browser process (the browser process will not exit until those other processes have closed their webviews too). Note this is an event from , not . The difference between BrowserProcessExited and is that BrowserProcessExited is raised for any browser process exit (expected or unexpected, after all associated processes have exited too), while is raised for unexpected process exits of any kind (browser, render, GPU, and all other types), or for main frame render process unresponsiveness. To learn more about the WebView2 Process Model, go to [Process model](/microsoft-edge/webview2/concepts/process-model). In the case the browser process crashes, both BrowserProcessExited and events are raised, but the order is not guaranteed. These events are intended for different scenarios. It is up to the app to coordinate the handlers so they do not try to perform reliability recovery while also trying to move to a new WebView2 Runtime version or remove the user data folder. :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="SubscribeToBrowserProcessExited"::: :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="BrowserProcessExited"::: Creates the used by the method. Gets the user data folder that all CoreWebView2s created from this environment are using. This could be either the value passed in by the developer when creating the environment object or the calculated one for default handling. And will always be an absolute path. ProcessInfosChanged is raised when a collection of WebView2 Runtime processes changed due to new process being detected or when a existing process gone away. Returns the list of all using same user data folder except for crashpad process. Create a custom object to insert into the WebView context menu. CoreWebView2 will rewind the icon stream before decoding. There is a limit of 1000 active custom context menu items at a given time per . Attempting to create more before deleting existing ones will fail with ERROR_NOT_ENOUGH_QUOTA. It is recommended to reuse custom ContextMenuItems across CoreWebView2ContextMenuRequested events for performance. The created object's property will default to true and property will default to false. A will be assigned that's unique across active custom context menu items, but command ID values of deleted custom ContextMenuItems can be reassigned. Creates a WebView2 Environment using the installed or a custom WebView2 Runtime version. The relative path to the folder that contains a custom version of WebView2 Runtime. To use a fixed version of the WebView2 Runtime, pass the folder path that contains the fixed version of the WebView2 Runtime to browserExecutableFolder. BrowserExecutableFolder supports both relative (to the application's executable) and absolute file paths. To create WebView2 controls that use the installed version of the WebView2 Runtime that exists on user machines, pass a null or empty string to browserExecutableFolder. In this scenario, the API tries to find a compatible version of the WebView2 Runtime that is installed on the user machine (first at the machine level, and then per user) using the selected channel preference. The path of fixed version of the WebView2 Runtime should not contain \Edge\Application\. When such a path is used, the API fails with ERROR_NOT_SUPPORTED. The user data folder location for WebView2. The path is either an absolute file path or a relative file path that is interpreted as relative to the compiled code for the current process. The default user data folder {Executable File Name}.WebView2 is created in the same directory next to the compiled code for the app. WebView2 creation fails if the compiled code is running in a directory in which the process does not have permission to create a new directory. The app is responsible to clean up the associated user data folder when it is done. Options used to create WebView2 Environment. As a browser process may be shared among WebViews, WebView creation fails if the specified options does not match the options of the WebViews that are currently running in the shared browser process. The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary. When an override WEBVIEW2_RELEASE_CHANNEL_PREFERENCE environment variable or applicable releaseChannelPreference registry value is set to 1, the channel search order is reversed. To use a fixed version of the WebView2 Runtime, pass the relative folder path that contains the fixed version of the WebView2 Runtime to browserExecutableFolder. To create WebView2 controls that use the installed version of the WebView2 Runtime that exists on user machines, pass a null or empty string to browserExecutableFolder. In this scenario, the API tries to find a compatible version of the WebView2 Runtime that is installed on the user machine (first at the machine level, and then per user) using the selected channel preference. The path of fixed version of the WebView2 Runtime should not contain \Edge\Application\. When such a path is used, the API fails with the following error. The , , and may be overridden by values either specified in environment variables or in the registry. When creating a the following environment variables are verified. WEBVIEW2_BROWSER_EXECUTABLE_FOLDER WEBVIEW2_USER_DATA_FOLDER WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS WEBVIEW2_RELEASE_CHANNEL_PREFERENCE If browser executable folder or user data folder is specified in an environment variable or in the registry, the specified or values are overridden. If additional browser arguments are specified in an environment variable or in the registry, it is appended to the corresponding value in the specified . While not strictly overrides, additional environment variables may be set. Value Description WEBVIEW2_WAIT_FOR_SCRIPT_DEBUGGER When found with a non-empty value, this indicates that the WebView is being launched under a script debugger. In this case, the WebView issues a Page.waitForDebugger CDP command that runs the script inside the WebView to pause on launch, until a debugger issues a corresponding Runtime.runIfWaitingForDebugger CDP command to resume the runtime. Note that this environment variable does not have a registry key equivalent. WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER When found with a non-empty value, it indicates that the WebView is being launched under a script debugger that also supports host apps that use multiple WebViews. The value is used as the identifier for a named pipe that is opened and written to when a new WebView is created by the host app. The payload should match the payload of the remote-debugging-port JSON target and an external debugger may use it to attach to a specific WebView instance. The format of the pipe created by the debugger should be \\.\pipe\WebView2\Debugger\{app_name}\{pipe_name}, where the following are true. {app_name} is the host app exe file name, for example, WebView2Example.exe {pipe_name} is the value set for WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER To enable debugging of the targets identified by the JSON, you must set the WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS environment variable to send --remote-debugging-port={port_num}, where the following is true. {port_num} is the port on which the CDP server binds. If both WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER and WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS environment variables, the WebViews hosted in your app and associated contents may exposed to 3rd party apps such as debuggers. Note that this environment variable does not have a registry key equivalent. If none of those environment variables exist, then the registry is examined next. [{Root}]\Software\Policies\Microsoft\Edge\WebView2\BrowserExecutableFolder "{AppId}"="" [{Root}]\Software\Policies\Microsoft\Edge\WebView2\ReleaseChannelPreference "{AppId}"="" [{Root}]\Software\Policies\Microsoft\Edge\WebView2\AdditionalBrowserArguments "{AppId}"="" [{Root}]\Software\Policies\Microsoft\Edge\WebView2\UserDataFolder "{AppId}"="" Use a group policy under Administrative Templates > Microsoft Edge WebView2 to configure browser executable folder and release channel preference. Value Description ERROR_DISK_FULL In the unlikely scenario where some instances of WebView are open during a browser update, the deletion of the previous WebView2 Runtime may be blocked. To avoid running out of disk space, a new WebView creation fails with this error if it detects that too many previous WebView2 Runtime versions exist. COREWEBVIEW2_MAX_INSTANCES The default maximum number of WebView2 Runtime versions allowed is 20. To override the maximum number of the previous WebView2 Runtime versions allowed, set the value of the following environment variable. ERROR_PRODUCT_UNINSTALLED If the Webview depends upon an installed WebView2 Runtime version and it is uninstalled, any subsequent creation fails with this error. First verify with Root as HKLM and then HKCU. AppId is first set to the Application User Model ID of the process, then if no corresponding registry key, the AppId is set to the compiled code name of the process, or if that is not a registry key then *. If an override registry key is found, use the browserExecutableFolder and userDataFolder registry values as replacements and append additionalBrowserArguments registry values for the corresponding values in the provided . Gets the browser version info including channel name if it is not the stable channel or WebView2 Runtime. The relative path to the folder that contains the WebView2 Runtime. WebView2 Runtime installation is missing. Gets the browser version info including channel name if it is not the stable channel or WebView2 Runtime. The relative path to the folder that contains the WebView2 Runtime. The environment options used to create the environment. WebView2 Runtime installation is missing. Browser version info includes channel name if it is not the WebView2 Runtime. Channel names are Beta, Dev, and Canary. The format of the return string matches the format of . If an override exists for BrowserExecutableFolder, ReleaseChannels, or ChannelSearchKind, the override is used. The presence of an override can result in a different channel used than the one expected based on the environment options object. BrowserExecutableFolder takes precedence over the other options. See for more details on overrides. If an override is not specified, then the parameters passed to GetAvailableBrowserVersionString are used. The method fails if the loader is unable to find an installed WebView2 Runtime or non-stable Microsoft Edge installation. Compares two instances of browser versions correctly and returns an integer that indicates whether the first instance is older, the same as, or newer than the second instance. One of the version strings to compare. The other version string to compare. An integer that indicates whether the first instance is older, the same as, or newer than the second instance. Value Type Condition Less than zero version1 is older than version2. Zero version1 is the same as version2. Greater than zero version1 is newer than version2. Creates a new object, which can be passed as a parameter in and function for multiple profiles support. A that can be passed when calling and . The options is a settable property while the default for profile name is an empty string and the default value for is false. The profile will be created on disk or opened when calling CreateCoreWebView2ControllerWithOptions no matter InPrivate mode is enabled or not, and it will be released in memory when the corresponding is closed but still remain on disk. As WebView2 is built on top of Edge browser, it follows Edge's behavior pattern. To create an InPrivate WebView, we get an off-the-record profile (an InPrivate profile) from a regular profile, then create the WebView with the off-the-record profile. Also the profile name can be reused. Set the path of the folder containing the `WebView2Loader.dll`. The path of the folder containing the `WebView2Loader.dll`. Thrown when `WebView2Loader.dll` has been successfully loaded. This function allows you to set the path of the folder containing the `WebView2Loader.dll`. This should be the path of a folder containing `WebView2Loader.dll` and not a path to the `WebView2Loader.dll` file itself. Note that the WebView2 SDK contains multiple `WebView2Loader.dll` files for different CPU architectures. When specifying folder path, you must specify one containing a `WebView2Loader.dll` module with a CPU architecture matching the current process CPU architecture. This function is used to load the `WebView2Loader.dll` module during calls to any other static methods on `CoreWebView2Environment`. So, the path should be specified before any other API is called in `CoreWebView2Environment` class. Once `WebView2Loader.dll` is successfully loaded this function will throw an InvalidOperationException exception. The path can be relative or absolute. Relative paths are relative to the path of the `Microsoft.Web.WebView2.Core.dll` module. If the `WebView2Loader.dll` file does not exist in that path or LoadLibrary cannot load the file, or LoadLibrary fails for any other reason, an exception corresponding to the LoadLibrary failure is thrown when any other API is called in `CoreWebView2Environment` class. For instance, if the file cannot be found a `DllNotFoundException` exception will be thrown. Options used to create WebView2 Environment. Default values will use your defaulted Edge WebView2 Runtime binaries and user data folder. Options used to create WebView2 Environment. Default values will use your defaulted Edge WebView2 Runtime binaries and user data folder. Gets or sets the additional browser arguments to change the behavior of the WebView. The arguments are passed to the browser process as part of the command. For more information about using command-line switches with Chromium browser processes, navigate to [Run Chromium with Flags](https://aka.ms/RunChromiumWithFlags). The value appended to a switch is appended to the browser process, for example, in --edge-webview-switches=xxx the value is xxx. If you specify a switch that is important to WebView functionality, it is ignored, for example, --user-data-dir. Specific features are disabled internally and blocked from being enabled. If a switch is specified multiple times, only the last instance is used. A merge of the different values of the same switch is not attempted, except for disabled and enabled features. The features specified by --enable-features and --disable-features will be merged with simple logic -- the features are the union of the specified features and built-in features. If a feature is disabled, it is removed from the enabled features list. If you specify command-line switches and sets this property, the --edge-webview-switches value takes precedence and is processed last. If a switch fails to parse, the switch is ignored. The default state for the operation is to run the browser process with no extra flags. Please note that calling this API twice will replace the previous value rather than appending to it. If there are multiple switches, there should be a space in between them. The one exception is if multiple features are being enabled/disabled for a single switch, in which case the features should be comma-separated. Ex. "--disable-features=feature1,feature2 --some-other-switch --do-something" Determines whether to enable single sign on with Azure Active Directory (AAD) resources inside WebView using the logged in Windows account and single sign on (SSO) with web sites using Microsoft account associated with the login in Windows account. The default value is false. Universal Windows Platform apps must also declare enterpriseCloudSSO [restricted capability](/windows/uwp/packaging/app-capability-declarations#restricted-capabilities) for the single sign on (SSO) to work. Gets or sets the default display language for WebView. It applies to browser UIs such as context menu and dialogs. It also applies to the accept-languages HTTP header that WebView sends to websites. The intended locale value is in the format of BCP 47 Language Tags. More information can be found from [IETF BCP47](https://www.ietf.org/rfc/bcp/bcp47.html). Gets or sets the version of the WebView2 Runtime binaries required to be compatible with your app. This defaults to the WebView2 Runtime version that corresponds with the version of the SDK the app is using. The format of this value is the same as the format of the property and other BrowserVersion values. Only the version part of the BrowserVersion value is respected. The channel suffix, if it exists, is ignored. The version of the WebView2 Runtime binaries actually used may be different from the specified TargetCompatibleBrowserVersion. The binaries are only guaranteed to be compatible. Verify the actual version on the property. Determines whether other processes can create from created with the same user data folder and therefore sharing the same WebView browser process instance. The default value is false. When IsCustomCrashReportingEnabled is set to true, Windows won't send crash data to Microsoft endpoint. The default value is false. In this case, WebView will respect OS consent. The EnableTrackingPrevention property is used to enable/disable tracking prevention feature in WebView2. This property enable/disable tracking prevention for all the WebView2's created in the same environment. By default this feature is enabled to block potentially harmful trackers and trackers from sites that aren't visited before and set to CoreWebView2TrackingPreventionLevel.Balanced or whatever value was last changed/persisted on the profile. You can set this property to false to disable the tracking prevention feature if the app only renders content in the WebView2 that is known to be safe. Disabling this feature when creating environment also improves runtime performance by skipping related code. You shouldn't disable this property if WebView2 is being used as a "full browser" with arbitrary navigation and should protect end user privacy. There is property to control levels of tracking prevention of the WebView2's associated with a same profile. However, you can also disable tracking prevention later using property and value but that doesn't improves runtime performance. See for more details. Tracking prevention protects users from online tracking by restricting the ability of trackers to access browser-based storage as well as the network. See [Tracking prevention](/microsoft-edge/web-platform/tracking-prevention). Enable/disable browser extensions. When AreBrowserExtensionsEnabled is set to true, new extensions can be added to user profile and used. AreBrowserExtensionsEnabled is default to be false, in this case, new extensions can't be installed, and already installed extension won't be available to use in user profile. If connecting to an already running environment with a different value for AreBrowserExtensionsEnabled property, it will fail with HRESULT_FROM_WIN32(ERROR_INVALID_STATE). See for Extensions API details. Set ChannelSearchKind to CoreWebView2ChannelSearchKind.LeastStable so that the WebView2 loader searches for binaries from least to most stable: Canary -> Dev -> Beta -> WebView2 Runtime. The ChannelSearchKind property is CoreWebView2ChannelSearchKind.MostStable by default and environment creation searches for a release channel on the machine from most to least stable using the first channel found. The default search order is: WebView2 Release -> Beta -> Dev -> Canary. Set ChannelSearchKind to CoreWebView2ChannelSearchKind.LeastStable to reverse the search order so that environment creation searches for a channel from least to most stable. If a ReleaseChannels has been provided, environment creation will only search for channels in the set. See for more details on channels. This property can be overridden by the corresponding registry key ChannelSearchKind or the environment variable WEBVIEW2_CHANNEL_SEARCH_KIND. Set the value to 1 to reverse the search order. See for more details on overrides. Sets the ReleaseChannels, which is a mask of one or more CoreWebView2ReleaseChannels indicating which channels environment creation should search for. OR operation(s) can be applied to multiple CoreWebView2ReleaseChannels to create a mask. The default value is a mask of all the channels. By default, environment creation searches for channels from most to least stable, using the first channel found on the device. When ReleaseChannels is provided, environment creation will only search for the channels specified in the set. Set ChannelSearchKind to CoreWebView2ChannelSearchKind.LeastStable to reverse the search order so that environment creation searches for the least stable build first. See for descriptions of each channel. Environment creation fails if it is unable to find any channel from the ReleaseChannels installed on the device. Use to verify which channel is used. If both a BrowserExecutableFolder and ReleaseChannels are provided, the BrowserExecutableFolder takes precedence. The ReleaseChannels can be overridden by the corresponding registry override ReleaseChannels or the environment variable WEBVIEW2_RELEASE_CHANNELS. Set the value to a comma-separated string of integers, which map to the following release channel values: Stable (0), Beta (1), Dev (2), and Canary (3). For example, the values "0,2" and "2,0" indicate that environment creation should only search for Dev channel and the WebView2 Runtime, using the order indicated by . Environment creation attempts to interpret each integer and treats any invalid entry as Stable channel. ReleaseChannelsChannel Search Kind: Most Stable (default)Channel Search Kind: Least StableCoreWebView2ReleaseChannels.Beta | CoreWebView2ReleaseChannels.StableWebView2 Runtime -> BetaBeta -> WebView2 RuntimeCoreWebView2ReleaseChannels.Canary | CoreWebView2ReleaseChannels.Dev | CoreWebView2ReleaseChannels.Beta | CoreWebView2ReleaseChannels.StableWebView2 Runtime -> Beta -> Dev -> CanaryCanary -> Dev -> Beta -> WebView2 RuntimeCoreWebView2ReleaseChannels.CanaryCanaryCanaryCoreWebView2ReleaseChannels.Beta | CoreWebView2ReleaseChannels.Canary | CoreWebView2ReleaseChannels.StableWebView2 Runtime -> Beta -> CanaryCanary -> Beta -> WebView2 Runtime Initializes a new instance of the CoreWebView2EnvironmentOptions class. AdditionalBrowserArguments can be specified to change the behavior of the WebView. The default language that WebView will run with. The version of the Edge WebView2 Runtime binaries required to be compatible with the calling application. Set to true if single sign on be enabled using the end user's OS primary account. Defaults to false. List of custom scheme registrations to be applied to the . Initializes a new instance of the CoreWebView2EnvironmentOptions class. AdditionalBrowserArguments can be specified to change the behavior of the WebView. The default language that WebView will run with. The version of the Edge WebView2 Runtime binaries required to be compatible with the calling application. Set to true if single sign on be enabled using the end user's OS primary account. Defaults to false. List of custom scheme registrations to be applied to the . Set to CoreWebView2ChannelSearchKind.LeastStable so that environment creation searches for binaries from least to most stable: Canary -> Dev -> Beta -> WebView2 Runtime. Defaults to CoreWebView2RuntimeChannel.MostStable. The release channels that are searched for during environment creation. List of custom scheme registrations to be applied to the The result for . If Succeeded is false, you can use this property to get the unhandled exception thrown by script execution A function that has no explicit return value returns undefined. If the script that was run throws an unhandled exception, then the result is also null. This property is true if successfully executed script with no unhandled exceptions and the result is available in the property. Representation of a DOM [File](https://developer.mozilla.org/docs/Web/API/File) object passed via WebMessage. You can use this object to obtain the path of a File dropped on WebView2. The absolute file path. Representation of a DOM [FileSystemHandle](https://developer.mozilla.org/docs/Web/API/FileSystemHandle) object. The kind of the FileSystemHandle. It can either be a file or a directory. The path to the FileSystemHandle. The permissions granted to the FileSystemHandle. CoreWebView2Frame provides direct access to the iframes information and handling. You can get a CoreWebView2Frame by handling the event. CoreWebView2Frame provides direct access to the iframes information and handling. The name of the iframe from the iframe html tag declaring it. Destroyed event is raised when the iframe corresponding to this object is removed or the document containing that iframe is destroyed. NameChanged is raised when the iframe changes its window.name property. Remove the host object specified by the name so that it is no longer accessible from JavaScript code in the iframe. While new access attempts are denied, if the object is already obtained by JavaScript code in the iframe, the JavaScript code continues to have access to that object. Calling this method for a name that is already removed or was never added fails. If the iframe is destroyed this method will return fail also. ContentLoading is raised before any content is loaded, including scripts added with . ContentLoading is not raised if a same page navigation occurs. This operation follows the event and precedes the and events. DOMContentLoaded is raised when the initial HTML document has been parsed. This aligns with the the document's DOMContentLoaded event in HTML. NavigationCompleted is raised when the current frame has completely loaded (body.onload has been raised) or loading stopped with error. NavigationStarting is raised when the current frame is requesting permission to navigate to a different URI. A frame navigation will raise a event and a event. All of the event handlers will be run before the event handlers. All of the event handlers share a common object. Whichever event handler is last to change the property will decide if the frame navigation will be cancelled. Redirects raise this event as well, and the navigation id is the same as the original one. You may block corresponding navigations until the event handler returns. WebMessageReceived is raised when the setting is set and the iframe runs window.chrome.webview.postMessage. The postMessage function is void postMessage(object) where object is any object supported by JSON conversion. When postMessage is called, the handler's Invoke method will be called with the object parameter postMessage converted to a JSON string. Runs JavaScript code from the javaScript parameter in the current frame. The JavaScript code to be run in the current frame.A JSON encoded string that represents the result of running the provided JavaScript. A function that has no explicit return value returns undefined. If the script that was run throws an unhandled exception, then the result is also null. This method is applied asynchronously. If the method is run before , the script will not be executed and the JSON null will be returned. This operation works even if is set to false. Posts the specified webMessageAsJson to the current frame. The web message to be posted to the iframe. The event args is an instance of MessageEvent. The setting must be true or the message will not be sent. The event arg's data property of the event arg is the webMessageAsJson string parameter parsed as a JSON string into a JavaScript object. The event arg's source property of the event arg is a reference to the window.chrome.webview object. For information about sending messages from the iframe to the host, navigate to . The message is sent asynchronously. If a navigation occurs before the message is posted to the iframe, the message is not be sent. Runs the message event of the window.chrome.webview of the iframe. JavaScript in that document may subscribe and unsubscribe to the event using the following code: ```javascript window.chrome.webview.addEventListener('message', handler) window.chrome.webview.removeEventListener('message', handler) ``` Posts a message that is a simple string rather than a JSON string representation of a JavaScript object. The web message to be posted to the iframe. This behaves in exactly the same manner as , but the data property of the event arg of the window.chrome.webview message is a string with the same value as webMessageAsString. Use this instead of if you want to communicate using simple strings rather than JSON objects. PermissionRequested is raised when content in an iframe or any of its descendant iframes requests permission to access some privileged resources. This relates to the PermissionRequested event on the CoreWebView2. Both these events will be raised in the case of an iframe requesting permission. The CoreWebView2Frame's event handlers will be invoked before the event handlers on the CoreWebView2. If the Handled property of the PermissionRequestedEventArgs is set to TRUE within the CoreWebView2Frame event handler, then the event will not be raised on the CoreWebView2, and it's event handlers will not be invoked. In the case of nested iframes, the PermissionRequested event will be raised from the top level iframe. If a deferral is not taken on the event args, the subsequent scripts are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. Share a shared buffer object with script of the iframe in the WebView. The object to be shared with script.The desired given to script.Additional data to be send to script. If it is not null or empty string, and it is not a valid JSON string, will be thrown. The script will receive a sharedbufferreceived event from chrome.webview. The event arg for that event will have the following methods and properties. PropertyDescriptiongetBuffer()A method that returns an ArrayBuffer object with the backing content from the shared buffer.additionalDataAn object as the result of parsing additionalDataAsJson as JSON string. This property will be undefined if additionalDataAsJson is nullptr or empty string.sourceWith a value set as chrome.webview object. If access is , the script will only have read access to the buffer. If the script tries to modify the content in a read only buffer, it will cause an access violation in WebView renderer process and crash the renderer process. If the shared buffer is already closed, the API throws with error code of RO_E_CLOSED. The script code should call chrome.webview.releaseBuffer with the shared buffer as the parameter to release underlying resources as soon as it does not need access to the shared buffer any more. The application can post the same shared buffer object to multiple web pages or iframes, or post to the same web page or iframe multiple times. Each PostSharedBufferToScript will create a separate ArrayBuffer object with its own view of the memory and is separately released. The underlying shared memory will be released when all the views are released. Sharing a buffer to script has security risk. You should only share buffer with trusted site. If a buffer is shared to a untrusted site, possible sensitive information could be leaked. If a buffer is shared as modifiable by the script and the script modifies it in an unexpected way, it could result in corrupted data that might even crash the application. The example code shows how to send data to script for one time read only consumption. :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="OneTimeShareBuffer"::: :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/assets/sharedBuffer.html" id="ShareBufferScriptCode_1"::: :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/assets/sharedBuffer.html" id="ShareBufferScriptCode_2"::: The unique identifier of the current frame. It's the same kind of ID as with the and . ScreenCaptureStarting event is raised when the [Screen Capture API](https://www.w3.org/TR/screen-capture/) is requested by the user using getDisplayMedia(). This relates to the ScreenCaptureStarting event on the CoreWebView2. Both these events will be raised in the case of an iframe requesting screen capture. The CoreWebView2Frame's event handlers will be invoked before the event handlers on the CoreWebView2. If the Handled property of the ScreenCaptureStartingEventArgs is set to TRUE within the CoreWebView2Frame event handler, then the event will not be raised on the CoreWebView2, and it's event handlers will not be invoked. In the case of nested iframes, if the ScreenCaptureStarting event is handled in the current nested iframe (i.e., the Handled property of the ScreenCaptureStartingEventArgs is set to TRUE), the event will not be raised on the parent CoreWebView2Frame. However, if the ScreenCaptureStarting event is not handled in that nested iframe, the event will be raised from its nearest tracked parent CoreWebView2Frame. It will iterate through the parent frame chain up to the main frame until a parent frame handles the request. If a deferral is not taken on the event args, the subsequent scripts are blocked until the event handler returns. If a deferral is taken, the scripts are blocked until the deferral is completed. FrameCreated is raised when a new direct descendant iframe is created. Handle this event to get access to objects. Use the to listen for when this iframe goes away. :::code language="csharp" source="../code/sample/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs" id="FrameChildFrameCreated"::: Adds the provided host object to script running in the WebViewFrame with the specified name for the list of the specified origins. The host object will be accessible for this iframe only if the iframe's origin during access matches one of the origins which are passed. The provided origins will be normalized before comparing to the origin of the document. So the scheme name is made lower case, the host will be punycode decoded as appropriate, default port values will be removed, and so on. This means the origin's host may be punycode encoded or not and will match regardless. If list contains malformed origin the call will fail. The method can be called multiple times in a row without calling RemoveHostObjectFromScript for the same object name. It will replace the previous object with the new object and new list of origins. List of origins will be treated as following: 1. empty list - call will succeed and object will be added for the iframe but it will not be exposed to any origin; 2. list with origins - during access to host object from iframe the origin will be checked that it belongs to this list; 3. list with "*" element - host object will be available for iframe for all origins. We suggest not to use this feature without understanding security implications of giving access to host object from from iframes with unknown origins. 4. list with "file://" element - host object will be available for iframes loaded via file protocol. The name of the host object. The host object to be added to script. The list of the iframe origins for which host object will be accessible. Event args for the event. Gets the created frame. Provides a set of properties for a frame in the . Gets the name attribute of the frame, as in ``. The returned string is empty when the frame has no name attribute. The URI of the document in the frame. The unique identifier of the frame associated with the current . It's the same kind of ID as with the and . FrameId will only be populated when obtained calling . objects obtained via will always have an invalid frame Id 0. FrameId could be out of date as it's a snapshot. If there's created or destroyed or event or event after the asynchronous call starts, you may want to call the asynchronous method again to get the updated `s. Gets the kind of the frame. FrameKind will only be populated when obtained calling . ` objects obtained via will always have the default value . FrameKind could be out of date as it's a snapshot. This parent frame's . ParentFrameInfo will only be populated when obtained via calling . objects obtained via will always have a null ParentFrameInfo. This property is also null for the top most document in the which has no parent frame. ParentFrameInfo could be out of date as it's a snapshot. Iterator for a collection of HTTP headers. true when the iterator has not run out of headers. If the collection over which the iterator is iterating is empty or if the iterator has gone past the end of the collection then this is false. No COM support; throws instead. No COM support. Gets the header in the or collection at the current position of the enumerator. HTTP request headers. Used to inspect the HTTP request on event and event. It is possible to modify the HTTP request headers from a event, but not from a event. Gets the header value matching the name. Gets the header value matching the name using a . The header value matching the name. Checks whether the headers contain an entry that matches the header name. Adds or updates header that matches the name. Removes header that matches the name. Gets a over the collection of request headers. Returns an enumerator that iterates through the or collection. HTTP response headers. Used to construct a for the event. Appends header line with name and value. The header name to be appended.The header value to be appended. Checks whether this CoreWebView2HttpResponseHeaders contain entries matching the header name. The name of the header to seek. Gets the first header value in the collection matching the name. The header name.The first header value in the collection matching the name. Gets the header values matching the name. Gets a over the collection of entire . Returns an enumerator that iterates through the or collection. Event args for the event. Determines whether to cancel the navigation. Gets the origin initiating the external URI scheme launch. The origin will be an empty string if the request is initiated by calling on the external URI scheme. If a script initiates the navigation, the `InitiatingOrigin` will be the top-level document's `Source`, i.e. if `window.location` is set to `"calculator://", the `InitiatingOrigin` will be set to `calculator://`. If the request is initiated from a child frame, the `InitiatingOrigin` will be the source of that child frame. If the `InitiatingOrigin` is [opaque](https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque), the `InitiatingOrigin` reported in the event args will be its precursor origin. The precursor origin is the origin that created the opaque origin. For example, if a frame on example.com opens a subframe with a different opaque origin, the subframe's precursor origin is example.com. true when the launching external URI scheme request was initiated through a user gesture. Gets the URI with the external URI scheme to be launched. Gets a Deferral object and puts the event into a deferred state. Use this to Complete the launching external URI scheme request at a later time. Event args for the event. Indicates whether the event has been handled by the app. If the app has moved the focus to another desired location, it should set Handled property to true. When Handled property is false after the event handler returns, default action is taken. The default action is to try to find the next tab stop child window in the app and try to move focus to that window. If no other window exists to move focus, focus is cycled within the web content of the WebView. Gets the reason for WebView to raise the event. Event args for the event. true when the navigation is successful; false for a navigation that ended up in an error page (failures due to no network, DNS lookup failure, HTTP server responds with 4xx). Note that WebView2 will report the navigation as 'unsuccessful' if the load for the navigation did not reach the expected completion for any reason. Such reasons include potentially catastrophic issues such network and certificate issues, but can also be the result of intended actions such as the app canceling a navigation or navigating away before the original navigation completed. Applications should not just rely on this flag, but also consider the reported WebErrorStatus to determine whether the failure is indeed catastrophic in their context. WebErrorStatuses that may indicate a non-catastrophic failure include: This may also be false for additional scenarios such as window.stop() run on navigated page. Gets the ID of the navigation. Gets the error code if the navigation failed. The HTTP status code of the navigation if it involved an HTTP request. For instance, this will usually be 200 if the request was successful, 404 if a page was not found, etc. See https://developer.mozilla.org/docs/Web/HTTP/Status for a list of common status codes. The HttpStatusCode property will be 0 in the following cases: The navigation did not involve an HTTP request. For instance, if it was a navigation to a file:// URL, or if it was a same-document navigation. The navigation failed before a response was received. For instance, if the hostname was not found, or if there was a network error. In those cases, you can get more information from the and properties. If the navigation receives a successful HTTP response, but the navigated page calls window.stop() before it finishes loading, then HttpStatusCode may contain a success code like 200, but will be false and will be . Since WebView2 handles HTTP continuations and redirects automatically, it is unlikely for HttpStatusCode to ever be in the 1xx or 3xx ranges. Event args for the event. Determines whether to cancel the navigation. If set to true, the navigation is no longer present and the content of the current page is intact. For performance reasons, GET HTTP requests may happen, while the host is responding. You may set cookies and use part of a request for the navigation. Navigations to about schemes are cancellable, unless `msWebView2CancellableAboutNavigations` feature flag is disabled. Cancellation of frame navigation to `srcdoc` is not supported and will be ignored. true when the navigation is redirected. true when the new window request was initiated through a user gesture. Examples of user initiated requests are: Selecting an anchor tag with targetProgrammatic window open from a script that directly run as a result of user interaction such as via onclick handlers. Non-user initiated requests are programmatic window opens from a script that are not directly triggered by user interaction, such as those that run while loading a new page or via timers. The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups. Gets the ID of the navigation. Gets the HTTP request headers for the navigation. Note, you are not able to modify the HTTP request headers in a event. Gets the uri of the requested navigation. Additional allowed frame ancestors set by the host app. The app may set this property to allow a frame to be embedded by additional ancestors besides what is allowed by http header [X-Frame-Options](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Frame-Options) and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors). If set, a frame ancestor is allowed if it is allowed by the additional allowed frame ancestors or original http header from the site. Whether an ancestor is allowed by the additional allowed frame ancestors is done the same way as if the site provided it as the source list of the Content-Security-Policy frame-ancestors directive. For example, if https://example.com and https://www.example.com are the origins of the top page and intermediate iframes that embed a nested site-embedding iframe, and you fully trust those origins, you should set this property to https://example.com https://www.example.com. This property gives the app the ability to use iframe to embed sites that otherwise could not be embedded in an iframe in trusted app pages. This could potentially subject the embedded sites to [Clickjacking](https://wikipedia.org/wiki/Clickjacking) attack from the code running in the embedding web page. Therefore, you should only set this property with origins of fully trusted embedding page and any intermediate iframes. Whenever possible, you should use the list of specific origins of the top and intermediate frames instead of wildcard characters for this property. This API is to provide limited support for app scenarios that used to be supported by <webview> element in other solutions like JavaScript UWP apps and Electron. You should limit the usage of this property to trusted pages, and specific navigation target url, by checking the , and . This property is ignored for top level document navigation. Gets the navigation kind of the navigation. Event args for the event. Indicates whether the event is handled by host. If this is false and no is set, the WebView opens a popup window and returns the opened WindowProxy to the opener script. Note that in this case, there is no avenue to control the popup window from the app. If set to true and no is set for window.open(), the opened proxy is for a dummy window object, but this window does not load and is immediately closed. The default value is false. true when the new window request was initiated through a user gesture such as selecting an anchor tag with target. The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups. Gets the new window or sets a WebView as a result of the new window requested. Provides a WebView as the target for a window.open() from inside the requesting WebView. If this is set, the top-level window of this WebView is returned as the opened [WindowProxy](https://developer.mozilla.org/docs/glossary/windowproxy) to the opener script. If this is not set, then is checked to determine behavior for the . The methods which should affect the new web contents like has to be called and completed before setting NewWindow. Other methods which should affect the new web contents like have to be called after setting NewWindow. It is best not to use before setting NewWindow, otherwise it may not work for later added scripts. WebView provided in the NewWindow property must be on the same as the opener WebView and cannot be navigated. Changes to settings should be made before setting NewWindow to ensure that those settings take effect for the newly setup WebView. The new WebView must have the same profile as the opener WebView. Gets the target uri of the new window request. Gets the window features specified by the window.open() call. These features should be considered for positioning and sizing of new WebView windows. Gets a Deferral object and put the event into a deferred state. Use this to Complete the window open request at a later time. While this event is deferred the opener window returns a WindowProxy to an un-navigated window, which navigates when the deferral is complete. Gets the name of the new window. This window can be created via window.open(url, windowName), where the windowName parameter corresponds to Name property. If no windowName is passed to `window.open`, then the `Name` property will be set to an empty string. Additionally, if window is opened through other means, such as `` or `