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/prerender.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,7 +199,7 @@ In the following example that serializes state for multiple components of the sa
199
199
}
200
200
```
201
201
202
-
In the following example that serializes state for a service:
202
+
In the following example that serializes state for a dependency injection service:
203
203
204
204
* Properties annotated with the `[SupplyParameterFromPersistentComponentState]` attribute are serialized during prerendering and deserialized when the app becomes interactive.
205
205
* The `AddPersistentService` method is used to register the service for persistence. The render mode is required because the render mode can't be inferred from the service type. Use any of the following values:
@@ -211,6 +211,8 @@ In the following example that serializes state for a service:
211
211
> [!NOTE]
212
212
> Only persisting scoped services is supported.
213
213
214
+
<!-- UPDATE 10.0 - Flesh out with a fully-working example. -->
Copy file name to clipboardExpand all lines: aspnetcore/blazor/fundamentals/static-files.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,9 +240,15 @@ In the project file (`.csproj`), the `<WriteImportMapToHtml>` property is set to
240
240
241
241
When resolving imports for JavaScript interop, the import map is used by the browser resolve fingerprinted files.
242
242
243
+
Any script in `index.html` with the fingerprint marker is fingerprinted by the framework. For example, a script file named `scripts.js` in the app's `wwwroot/js` folder is fingerprinted by adding `#[.{fingerprint}]` before the file extension (`.js`):
## Fingerprint client-side static assets in Blazor Web Apps
244
250
245
-
For client-side rendering (CSR) in Blazor Web Apps (Interactive Auto or Interactive WebAssembly render modes), static asset server-side [fingerprinting](https://wikipedia.org/wiki/Fingerprint_(computing)) is enabled by adopting [Map Static Assets routing endpoint conventions (`MapStaticAssets`)](xref:fundamentals/map-static-files), [`ImportMap` component](xref:blazor/fundamentals/static-files#importmap-component), and the <xref:Microsoft.AspNetCore.Components.ComponentBase.Assets?displayProperty=nameWithType> property (`@Assets["..."]`).
251
+
For client-side rendering (CSR) in Blazor Web Apps (Interactive Auto or Interactive WebAssembly render modes), static asset server-side [fingerprinting](https://wikipedia.org/wiki/Fingerprint_(computing)) is enabled by adopting [Map Static Assets routing endpoint conventions (`MapStaticAssets`)](xref:fundamentals/map-static-files), [`ImportMap` component](xref:blazor/fundamentals/static-files#importmap-component), and the <xref:Microsoft.AspNetCore.Components.ComponentBase.Assets?displayProperty=nameWithType> property (`@Assets["..."]`). For more information, see <xref:fundamentals/map-static-files>.
246
252
247
253
To fingerprint additional JavaScript modules for CSR, use the `<StaticWebAssetFingerprintPattern>` item in the app's project file (`.csproj`). In the following example, a fingerprint is added for all developer-supplied `.mjs` files in the app:
*[In-memory state container service](#in-memory-state-container-service)
64
77
*[Cascading values and parameters](#cascading-values-and-parameters)
65
78
79
+
:::moniker-end
80
+
81
+
:::moniker range=">= aspnetcore-10.0"
82
+
83
+
<h2id="declarative-model-for-persisting-state-server">Declarative model for persisting state</h2>
84
+
85
+
<!-- UPDATE 10.0 - API cross-link -->
86
+
87
+
Establish declarative state in a dependency injection service for use around the app by calling `RegisterPersistentService` on the Razor components builder (<xref:Microsoft.Extensions.DependencyInjection.RazorComponentsServiceCollectionExtensions.AddRazorComponents%2A>) with a custom service type and render mode. For more information, see <xref:blazor/components/prerender#persist-prerendered-state>.
For permanent data persistence that spans multiple users and devices, the app can use server-side storage. Options include:
@@ -618,12 +643,37 @@ An app can only persist *app state*. UIs can't be persisted, such as component i
618
643
619
644
Common locations exist for persisting state:
620
645
646
+
:::moniker range=">= aspnetcore-10.0"
647
+
648
+
*[Declarative model for persistent state](#declarative-model-for-persisting-state-wasm)
649
+
*[Server-side storage](#server-side-storage-wasm)
650
+
*[URL](#url-wasm)
651
+
*[Browser storage](#browser-storage-wasm)
652
+
*[In-memory state container service](#in-memory-state-container-service)
653
+
*[Cascading values and parameters](#cascading-values-and-parameters)
654
+
655
+
:::moniker-end
656
+
657
+
:::moniker range="< aspnetcore-10.0"
658
+
621
659
*[Server-side storage](#server-side-storage-wasm)
622
660
*[URL](#url-wasm)
623
661
*[Browser storage](#browser-storage-wasm)
624
662
*[In-memory state container service](#in-memory-state-container-service)
625
663
*[Cascading values and parameters](#cascading-values-and-parameters)
626
664
665
+
:::moniker-end
666
+
667
+
:::moniker range=">= aspnetcore-10.0"
668
+
669
+
<h2id="declarative-model-for-persisting-state-wasm">Declarative model for persisting state</h2>
670
+
671
+
<!-- UPDATE 10.0 - API cross-link -->
672
+
673
+
Establish declarative state in a dependency injection service for use around the app by calling `RegisterPersistentService` on the Razor components builder (<xref:Microsoft.Extensions.DependencyInjection.RazorComponentsServiceCollectionExtensions.AddRazorComponents%2A>) with a custom service type and render mode. For more information, see <xref:blazor/components/prerender#persist-prerendered-state>.
For permanent data persistence that spans multiple users and devices, the app can use independent server-side storage accessed via a web API. Options include:
Copy file name to clipboardExpand all lines: aspnetcore/release-notes/aspnetcore-10/includes/blazor.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,7 +130,7 @@ Last year, the release of .NET 9 introduced [server-side fingerprinting](https:/
130
130
131
131
In standalone Blazor WebAssembly apps during build/publish, the framework overrides placeholders in `index.html` with values computed during build to fingerprint static assets. A fingerprint is placed into the `blazor.webassembly.js` script file name.
132
132
133
-
The following changes must be made in the `wwwwoot/index.html` file to adopt the fingerprinting feature. The standalone Blazor WebAssembly project template will be updated to include these changes in an upcoming preview release:
133
+
The following markup must be present in the `wwwwoot/index.html` file to adopt the fingerprinting feature:
134
134
135
135
```diff
136
136
<head>
@@ -161,6 +161,12 @@ In the project file (`.csproj`), add the `<WriteImportMapToHtml>` property set t
161
161
</Project>
162
162
```
163
163
164
+
Any script in `index.html` with the fingerprint marker is fingerprinted by the framework. For example, a script file named `scripts.js` in the app's `wwwroot/js` folder is fingerprinted by adding `#[.{fingerprint}]` before the file extension (`.js`):
To fingerprint additional JS modules in standalone Blazor WebAssembly apps, use the `<StaticWebAssetFingerprintPattern>` property in the app's project file (`.csproj`).
165
171
166
172
In the following example, a fingerprint is added for all developer-supplied `.mjs` files in the app:
@@ -281,7 +287,7 @@ else
281
287
}
282
288
```
283
289
284
-
For more information, see <xref:blazor/components/prerender?view=aspnetcore-10.0#persist-prerendered-state>. Additional API implementation notes, which are subject to change at any time, are available in [[Blazor] Support for declaratively persisting component and services state (`dotnet/aspnetcore`#60634)](https://github.com/dotnet/aspnetcore/pull/60634).
290
+
State can be serialized for multiple components of the same type, and you can establish declarative state in a service for use around the app by calling `RegisterPersistentService` on the Razor components builder (<xref:Microsoft.Extensions.DependencyInjection.RazorComponentsServiceCollectionExtensions.AddRazorComponents%2A>) with a custom service type and render mode. For more information, see <xref:blazor/components/prerender?view=aspnetcore-10.0#persist-prerendered-state>.
0 commit comments