You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/sections.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn how to control the content in a Razor component from a child
5
5
monikerRange: '>= aspnetcore-8.0'
6
6
ms.author: wpickett
7
7
ms.custom: mvc
8
-
ms.date: 11/12/2024
8
+
ms.date: 09/10/2025
9
9
uid: blazor/components/sections
10
10
---
11
11
# ASP.NET Core Blazor sections
@@ -85,6 +85,10 @@ When the `Counter` component is accessed, the `MainLayout` component renders the
85
85
> [!NOTE]
86
86
> <xref:Microsoft.AspNetCore.Components.Sections.SectionOutlet> and <xref:Microsoft.AspNetCore.Components.Sections.SectionContent> components can only set either <xref:Microsoft.AspNetCore.Components.Sections.SectionOutlet.SectionId%2A> or <xref:Microsoft.AspNetCore.Components.Sections.SectionOutlet.SectionName%2A>, not both.
87
87
88
+
## `RenderFragment` caching rules and section rendering behavior
89
+
90
+
When a <xref:Microsoft.AspNetCore.Components.Sections.SectionContent>'s <xref:Microsoft.AspNetCore.Components.RenderFragment> content changes, which is a different instance than the component where it's rendered, Blazor completely destroys and recreates the section instead of attempting to update the section's content. Unlike normal rendering, the section's content could come from different instances, and it doesn't make sense to attempt processing content from two separate components, which might lead to unexpected results. For a detailed explanation on this behavior, see [Inconsistent component initialization with Blazor SectionOutlet/SectionContent and CascadingValue (`dotnet/aspnetcore`#58316)](https://github.com/dotnet/aspnetcore/issues/58316).
91
+
88
92
## Section interaction with other Blazor features
89
93
90
94
A section interacts with other Blazor features in the following ways:
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/passkeys/blazor.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,9 @@ title: Implement passkeys in ASP.NET Core Blazor Web Apps
3
3
author: guardrex
4
4
description: Learn how to implement passkeys authentication in ASP.NET Core Blazor Web Apps.
5
5
ms.author: wpickett
6
+
monikerRange: '>= aspnetcore-10.0'
6
7
ms.custom: mvc
7
-
ms.date: 09/08/2025
8
+
ms.date: 09/10/2025
8
9
uid: security/authentication/passkeys/blazor
9
10
zone_pivot_groups: implementation
10
11
---
@@ -237,23 +238,26 @@ Add the following `RenamePasskey` component for renaming passkeys and update the
237
238
238
239
Add a link to the passkey management page in the app's `ManageNavMenu` component.
239
240
240
-
In `Components/Account/Shared/ManageNavMenu.razor`:
241
+
In `Components/Account/Shared/ManageNavMenu.razor`, add the following [`NavLink` component](xref:blazor/fundamentals/routing#navlink-component) for the `Passkeys` component:
@@ -279,6 +283,14 @@ After a passkey is registered:
279
283
1. Navigate to `Account/Manage/Passkeys` to add, rename, or delete passkeys.
280
284
1. If the passkey supports passkey autofill (conditional UI) for login, test the passkey autofill feature by selecting the email input field when you have saved passkeys.
Some password managers don't implement the [`PublicKeyCredential.toJSON` method](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/toJSON) correctly, which is required for [`JSON.stringify`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) to work when serializing passkey credentials. When registering or authenticating a user with an app based on the Blazor Web App project template, the following error is thrown when attempting to add a passkey:
289
+
290
+
> :::no-loc text="Error: Could not add a passkey: Illegal invocation":::
291
+
292
+
For guidance on mitigating this error, see <xref:security/authentication/passkeys/index#mitigate-publickeycredentialtojson-error-typeerror-illegal-invocation>.
293
+
282
294
## Additional resources
283
295
284
296
*[Web Authentication API (MDN documentation)](https://developer.mozilla.org/docs/Web/API/Web_Authentication_API)
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/passkeys/index.md
+89-1Lines changed: 89 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ author: guardrex
4
4
description: Discover how to enable Web Authentication API (WebAuthn) passkeys in ASP.NET Core apps.
5
5
ms.author: wpickett
6
6
monikerRange: '>= aspnetcore-10.0'
7
-
ms.date: 09/08/2025
7
+
ms.custom: mvc
8
+
ms.date: 09/10/2025
8
9
uid: security/authentication/passkeys/index
9
10
---
10
11
# Enable Web Authentication API (WebAuthn) passkeys
@@ -573,6 +574,93 @@ For scenarios requiring more control, you can use `PerformPasskeyAssertionAsync`
573
574
574
575
Upon successful authentication, ASP.NET Core Identity establishes an authenticated session for the user. The `PasskeySignInAsync` method handles this automatically, creating the necessary authentication cookies and claims. The app then redirects the user to protected resources or display personalized content.
The [`PublicKeyCredential.toJSON` method](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/toJSON) returns a JSON representation of a [`PublicKeyCredential`](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential). The method is invoked by the password manager when the app attempts to serialize a `PublicKeyCredential` by calling [`JSON.stringify`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) while registering or authenticating a user.
580
+
581
+
Some password managers don't implement the `PublicKeyCredential.toJSON` method correctly, which is required for `JSON.stringify` to work when serializing passkey credentials. When registering or authenticating a user with an app based on the Blazor Web App project template, the following error is thrown by some password managers when attempting to add a passkey:
582
+
583
+
> :::no-loc text="Error: Could not add a passkey: Illegal invocation":::
584
+
585
+
Until your selected password manager is updated to implement the `PublicKeyCredential.toJSON` method correctly, make the following changes to the app. The following code manually JSON serializes the `PublicKeyCredential`.
586
+
587
+
In the `Components/Account/Shared/PasskeySubmit.razor.js` file, locate the `passkey-submit` custom element definition code block:
Add the following `convertToBase64` function to the code block:
596
+
597
+
```javascript
598
+
convertToBase64(o) {
599
+
if (!o) {
600
+
returnundefined;
601
+
}
602
+
603
+
// Normalize Array to Uint8Array
604
+
if (Array.isArray(o)) {
605
+
o =Uint8Array.from(o);
606
+
}
607
+
608
+
// Normalize ArrayBuffer to Uint8Array
609
+
if (o instanceofArrayBuffer) {
610
+
o =newUint8Array(o);
611
+
}
612
+
613
+
// Convert Uint8Array to base64
614
+
if (o instanceofUint8Array) {
615
+
let str ='';
616
+
for (let i =0; i <o.byteLength; i++) {
617
+
str +=String.fromCharCode(o[i]);
618
+
}
619
+
o =window.btoa(str);
620
+
}
621
+
622
+
if (typeof o !=='string') {
623
+
thrownewError("Could not convert to base64 string");
624
+
}
625
+
626
+
// Convert base64 to base64url
627
+
o =o.replace(/\+/g, "-").replace(/\//g, "_").replace(/=*$/g, "");
628
+
629
+
return o;
630
+
}
631
+
```
632
+
633
+
In the `obtainAndSubmitCredential` function of the code block, locate the line that calls `JSON.stringify` with the user's credential and remove the line:
The preceding workaround is only required until the password manager is updated to implement the `PublicKeyCredential.toJSON` method correctly. We recommend tracking your password manager's release notes and reverting the preceding changes after the password manager is updated.
663
+
576
664
## Additional resources
577
665
578
666
* [Web Authentication API (MDN documentation)](https://developer.mozilla.org/docs/Web/API/Web_Authentication_API)
0 commit comments