Compartir a través de


CoreWebView2CustomSchemeRegistration Class

Definition

Represents the registration of a custom scheme with the CoreWebView2Environment.

public class CoreWebView2CustomSchemeRegistration
type CoreWebView2CustomSchemeRegistration = class
Public Class CoreWebView2CustomSchemeRegistration
Inheritance
CoreWebView2CustomSchemeRegistration

Examples

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.

Remarks

This allows the WebView2 app to be able to handle WebResourceRequested 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 For WebResourceRequested 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 and adheres to

CSP. The app needs to set the appropriate access headers in its WebResourceRequested event handler to allow CORS requests.

Constructors

CoreWebView2CustomSchemeRegistration(String)

Initializes a new instance of the CoreWebView2CustomSchemeRegistration class.

Properties

AllowedOrigins

List of origins that are allowed to issue requests with the custom scheme, such as XHRs and subresource requests that have an Origin header.

HasAuthorityComponent

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.

URIRecommended HasAuthorityComponent value
custom-scheme-with-authority://host/pathtrue
custom-scheme-without-authority:pathfalse
SchemeName

The name of the custom scheme to register.

TreatAsSecure

Whether the sites with this scheme will be treated as a Secure Context like an HTTPS site.

Applies to