Help Center

CWebView2.AddWebResourceRequestedFiltermethod

This method is deprecated and does not behave as expected for iframes.

WebViewmethoddocumented

Syntax

FUNCTION AddWebResourceRequestedFilter (BYVAL uri AS LPCWSTR, BYVAL ResourceContext AS COREWEBVIEW2_WEB_RESOURCE_CONTEXT) AS HRESULT
Also documented as RemoveWebResourceRequestedFilter — one description covers them all.

Parameters

NameDescription
uriThe URI to add.
ResourceContextThe resource context filter.

Description

Warning: This method is deprecated and does not behave as expected for iframes.

It will cause the WebResourceRequested event to fire only for the main frame and its same-origin iframes. Please use AddWebResourceRequestedFilterWithRequestSourceKinds instead, which will let the event to fire for all iframes on the document.

Adds a URI and resource context filter for the WebResourceRequested event. 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.

Remarks

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.

Reference

  • Defined in AfxNova/CWebView2.inc:1615
  • Documented in WebView/CWebWiew2 Class.md
  • Topic: CWebView2 Class