interface ICoreWebView2Experimental10

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

Note

This an experimental API that is shipped with our prerelease SDK. See WebView2 release notes.

interface ICoreWebView2Experimental10
  : public IUnknown

This interface is an extension of ICoreWebView2 that supports BasicAuthenticationRequested event.

Summary

Members Descriptions
add_BasicAuthenticationRequested Add an event handler for the BasicAuthenticationRequested event.
remove_BasicAuthenticationRequested Remove an event handler previously added with add_WebResourceRequested.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease 1.0.1056

Members

add_BasicAuthenticationRequested

Add an event handler for the BasicAuthenticationRequested event.

public HRESULT add_BasicAuthenticationRequested(ICoreWebView2ExperimentalBasicAuthenticationRequestedEventHandler * eventHandler, EventRegistrationToken * token)

BasicAuthenticationRequested event is raised when WebView encounters a Basic HTTP Authentication request as described in https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication or an NTLM authentication request.

The host can provide a response with credentials for the authentication or cancel the request. If the host doesn't set the Cancel property to true or set either UserName or Password properties on the Response property, then WebView2 will show the default authentication challenge dialog prompt to the user.

    if (auto webViewExperimental10 = m_webView.try_query<ICoreWebView2Experimental10>())
    {
        CHECK_FAILURE(webViewExperimental10->add_BasicAuthenticationRequested(
            Callback<ICoreWebView2ExperimentalBasicAuthenticationRequestedEventHandler>(
                [this](
                    ICoreWebView2* sender,
                    ICoreWebView2ExperimentalBasicAuthenticationRequestedEventArgs* args) {
                    wil::com_ptr<ICoreWebView2ExperimentalBasicAuthenticationResponse> basicAuthenticationResponse;
                    CHECK_FAILURE(args->get_Response(&basicAuthenticationResponse));
                    CHECK_FAILURE(basicAuthenticationResponse->put_UserName(L"user"));
                    CHECK_FAILURE(basicAuthenticationResponse->put_Password(L"pass"));

                    return S_OK;
                })
                .Get(),
            &m_basicAuthenticationRequestedToken));
    }
    else {
        FeatureNotAvailable();
    }

remove_BasicAuthenticationRequested

Remove an event handler previously added with add_WebResourceRequested.

public HRESULT remove_BasicAuthenticationRequested(EventRegistrationToken token)