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/fundamentals/static-files.md
+23-28Lines changed: 23 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,11 +196,19 @@ For examples of how to address the policy violation with Subresource Integrity (
196
196
197
197
:::moniker-end
198
198
199
+
:::moniker range="< aspnetcore-9.0"
200
+
201
+
Configure Static File Middleware to serve static assets to clients by calling <xref:Microsoft.AspNetCore.Builder.StaticFileExtensions.UseStaticFiles%2A> in the app's request processing pipeline. For more information, see <xref:fundamentals/static-files>.
202
+
203
+
In releases prior to .NET 8, Blazor framework static files, such as the Blazor script, are served via Static File Middleware. In .NET 8 or later, Blazor framework static files are mapped using endpoint routing, and Static File Middleware is no longer used.
204
+
205
+
:::moniker-end
206
+
199
207
:::moniker range=">= aspnetcore-10.0"
200
208
201
-
###Fingerprint client-side static assets
209
+
## Fingerprint client-side static assets in standalone Blazor WebAssembly apps
202
210
203
-
In standalone Blazor WebAssembly apps during build/publish, the framework overrides placeholders in `index.html` with values computed during build to fingerprint static assets for client-side rendering (CSR). A [fingerprint](https://en.wikipedia.org/wiki/Fingerprint_(computing)) is placed into the `blazor.webassembly.js` script file name, and an import map is generated for other .NET assets.
211
+
In standalone Blazor WebAssembly apps during build/publish, the framework overrides placeholders in `index.html` with values computed during build to fingerprint static assets for client-side rendering. A [fingerprint](https://wikipedia.org/wiki/Fingerprint_(computing)) is placed into the `blazor.webassembly.js` script file name, and an import map is generated for other .NET assets.
204
212
205
213
The following configuration must be present in the `wwwwoot/index.html` file of a standalone Blazor WebAssembly app to adopt fingerprinting:
206
214
@@ -223,43 +231,30 @@ The following configuration must be present in the `wwwwoot/index.html` file of
223
231
In the project file (`.csproj`), the `<OverrideHtmlAssetPlaceholders>` property is set to `true`:
For CSR in Blazor Web Apps (Interactive Auto or Interactive WebAssembly render modes), static asset server-side fingerprinting is enabled by adopting [Map Static Assets routing endpoint conventions (`MapStaticAssets`)](xref:fundamentals/map-static-files) and the [`ImportMap` component](xref:blazor/fundamentals/static-files#importmap-component).
239
+
When resolving imports for JavaScript interop, the import map is used by the browser resolve fingerprinted files.
236
240
237
-
To fingerprint additional JavaScript modules for CSR, use the `<StaticWebAssetFingerprintPattern>` property in the app's project file (`.csproj`).
241
+
## Fingerprint client-side static assets in Blazor Web Apps
238
242
239
-
In the following example, a fingerprint is added for all developer-supplied `.mjs` files in the app:
243
+
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["..."]`).
244
+
245
+
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:
The files are automatically placed into the import map:
247
-
248
-
* Automatically for Blazor Web App CSR.
249
-
* When opting-into module fingerprinting in standalone Blazor WebAssembly apps per the preceding instructions.
250
-
251
-
When resolving the import for JavaScript interop, the import map is used by the browser resolve fingerprinted files.
254
+
When resolving imports for JavaScript interop, the import map is used by the browser resolve fingerprinted files.
252
255
253
256
:::moniker-end
254
257
255
-
:::moniker range="< aspnetcore-9.0"
256
-
257
-
Configure Static File Middleware to serve static assets to clients by calling <xref:Microsoft.AspNetCore.Builder.StaticFileExtensions.UseStaticFiles%2A> in the app's request processing pipeline. For more information, see <xref:fundamentals/static-files>.
258
-
259
-
:::moniker-end
260
-
261
-
In releases prior to .NET 8, Blazor framework static files, such as the Blazor script, are served via Static File Middleware. In .NET 8 or later, Blazor framework static files are mapped using endpoint routing, and Static File Middleware is no longer used.
262
-
263
258
## Summary of static file `<link>``href` formats
264
259
265
260
*This section applies to all .NET releases and Blazor apps.*
0 commit comments