Skip to content

Commit 7055a7c

Browse files
author
Cagri Yildirim
committed
Update WebAuthenticationRequested.md
1 parent d2e4639 commit 7055a7c

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

specs/WebAuthenticationRequested.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ The developer can provide the authentication credentials on behalf of the user w
4545
{
4646
wil::com_ptr<ICoreWebView2Deferral> deferral;
4747

48-
// Ensure the event args are retained for the lambda.
49-
wil::com_ptr<ICoreWebView2BasicAuthenticationRequestedEventArgs> web_auth_args = args;
5048
args->GetDeferral(&deferral);
51-
ShowCustomLoginUI().then([web_auth_args, deferral](LPCWSTR userName, LPCWSTR password)
49+
ShowCustomLoginUI().then([web_auth_args = wil::make_com_ptr(args), deferral](LPCWSTR userName, LPCWSTR password)
5250
{
5351
wil::com_ptr<ICoreWebView2BasicAuthenticationResponse> basicAuthenticationResponse;
5452
CHECK_HRESULT(web_auth_args->get_Response(&basicAuthenticationResponse));
@@ -66,11 +64,13 @@ The developer can provide the authentication credentials on behalf of the user w
6664
```c#
6765
webView.CoreWebView2.BasicAuthenticationRequested += delegate (object sender, CoreWebView2BasicAuthenticationRequestedEventArgs args)
6866
{
69-
CoreWebView2Deferral deferral = args.GetDeferral();
70-
Credential credential = await ShowCustomLoginUIAsync();
71-
args.Response.UserName = credential.UserName;
72-
args.Response.Password = credential.Password;
73-
deferral.Complete();
67+
using (CoreWebView2Deferral deferral = args.GetDeferral())
68+
{
69+
Credential credential = await ShowCustomLoginUIAsync();
70+
args.Response.UserName = credential.UserName;
71+
args.Response.Password = credential.Password;
72+
deferral.Complete();
73+
}
7474
};
7575
```
7676

@@ -149,11 +149,11 @@ interface ICoreWebView2_4 : ICoreWebView2_3
149149
/// Add an event handler for the BasicAuthenticationRequested event.
150150
/// BasicAuthenticationRequested event is raised when WebView encounters a Basic HTTP
151151
/// Authentication request as described in
152-
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication.
152+
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication or an NTLM authentication request.
153153
///
154154
/// The host can provide a response with credentials for the authentication or
155155
/// cancel the request. If the host doesn't set the Cancel property to true or
156-
/// populate the Response property, then WebView2 will show the default
156+
/// set either UserName or Password properties on the Response property, then WebView2 will show the default
157157
/// authentication challenge dialog prompt to the user.
158158
///
159159
HRESULT add_BasicAuthenticationRequested(
@@ -244,7 +244,7 @@ namespace Microsoft.Web.WebView2.Core
244244

245245
/// Returns an `ICoreWebView2Deferral` object. Use this deferral to
246246
/// defer the decision to show the Basic Authentication dialog.
247-
CoreWebView2Deferral Deferral { get; };
247+
CoreWebView2Deferral GetDeferral();
248248
}
249249

250250
/// Represents a Basic HTTP authentication response that contains a user name

0 commit comments

Comments
 (0)