Share via


CoreWebView2.AddWebResourceRequestedFilter Method

Definition

Overloads

AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext)

Warning: This method is deprecated and does not behave as expected for iframes. Please use AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext, CoreWebView2WebResourceRequestSourceKinds) instead. Adds a URI and resource context filter for the WebResourceRequested event.

AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext, CoreWebView2WebResourceRequestSourceKinds)

Adds a URI and resource context filter for corresponding request sources for the WebResourceRequested event.

AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext)

Warning: This method is deprecated and does not behave as expected for iframes. Please use AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext, CoreWebView2WebResourceRequestSourceKinds) instead. Adds a URI and resource context filter for the WebResourceRequested event.

public void AddWebResourceRequestedFilter (string uri, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext ResourceContext);
member this.AddWebResourceRequestedFilter : string * Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext -> unit
Public Sub AddWebResourceRequestedFilter (uri As String, ResourceContext As CoreWebView2WebResourceContext)

Parameters

uri
String

An URI to be added to the WebResourceRequested event.

ResourceContext
CoreWebView2WebResourceContext

A resource context filter to be added to the WebResourceRequested event.

Remarks

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 will be raised via the WebResourceRequested event.

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 nullptr for the uri is equivalent to an empty string which matches no URIs.

For more information about resource context filters, navigate to CoreWebView2WebResourceContext.

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 URI
examplehttps://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 URI
https://xn--qei.example/https://❤.example/YesNon-ASCII hostnames are normalized to punycode before wildcard comparison
https://❤.example/https://xn--qei.example/NoNon-ASCII hostnames are normalized to punycode before wildcard comparison

See also

Applies to

AddWebResourceRequestedFilter(String, CoreWebView2WebResourceContext, CoreWebView2WebResourceRequestSourceKinds)

Adds a URI and resource context filter for corresponding request sources for the WebResourceRequested event.

public void AddWebResourceRequestedFilter (string uri, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext ResourceContext, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestSourceKinds RequestSourceKinds);
public void AddWebResourceRequestedFilter (string uri, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext ResourceContext, Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestSourceKinds requestSourceKinds);
member this.AddWebResourceRequestedFilter : string * Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext * Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestSourceKinds -> unit
member this.AddWebResourceRequestedFilter : string * Microsoft.Web.WebView2.Core.CoreWebView2WebResourceContext * Microsoft.Web.WebView2.Core.CoreWebView2WebResourceRequestSourceKinds -> unit
Public Sub AddWebResourceRequestedFilter (uri As String, ResourceContext As CoreWebView2WebResourceContext, RequestSourceKinds As CoreWebView2WebResourceRequestSourceKinds)
Public Sub AddWebResourceRequestedFilter (uri As String, ResourceContext As CoreWebView2WebResourceContext, requestSourceKinds As CoreWebView2WebResourceRequestSourceKinds)

Parameters

uri
String

A URI to be added to the WebResourceRequested event.

ResourceContext
CoreWebView2WebResourceContext

A resource context filter to be added to the WebResourceRequested event.

RequestSourceKindsrequestSourceKinds
CoreWebView2WebResourceRequestSourceKinds

A request source filter to be added to the WebResourceRequested event.

Applies to