Skip to content

Commit b1f7640

Browse files
authored
Merge pull request #35139 from dotnet/main
2 parents 190ceae + 6da56e8 commit b1f7640

File tree

8 files changed

+30
-62
lines changed

8 files changed

+30
-62
lines changed

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,16 @@
13871387
"source_path": "aspnetcore/blazor/host-and-deploy/server.md",
13881388
"redirect_url": "/aspnet/core/blazor/host-and-deploy/server/",
13891389
"redirect_document_id": false
1390+
},
1391+
{
1392+
"source_path": "aspnetcore/blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching.md",
1393+
"redirect_url": "/aspnet/core/blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures",
1394+
"redirect_document_id": false
1395+
},
1396+
{
1397+
"source_path": "aspnetcore/blazor/host-and-deploy/webassembly/integrity-check-failures.md",
1398+
"redirect_url": "/aspnet/core/blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures",
1399+
"redirect_document_id": false
13901400
}
13911401
]
13921402
}

aspnetcore/blazor/fundamentals/startup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ When the `loadBootResource` function returns `null`, Blazor uses the default loa
489489

490490
The `loadBootResource` function can also return a [`Response` promise](https://developer.mozilla.org/docs/Web/API/Response). For an example, see <xref:blazor/host-and-deploy/webassembly/index#compression>.
491491

492-
For more information, see <xref:blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching>.
492+
For more information, see <xref:blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures>.
493493

494494
## Control headers in C# code
495495

aspnetcore/blazor/host-and-deploy/webassembly/Integrity-check-failures.md renamed to aspnetcore/blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
---
2-
title: Resolve integrity check failures in ASP.NET Core Blazor WebAssembly apps
2+
title: ASP.NET Core Blazor WebAssembly .NET bundle caching and integrity check failures
33
author: guardrex
4-
description: Learn how to resolve integrity check failures in Blazor WebAssembly apps.
4+
description: Learn about WebAssembly .NET app and runtime bundle caching and how to resolve integrity check failures in Blazor WebAssembly apps.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 03/31/2025
9-
uid: blazor/host-and-deploy/webassembly/integrity-check-failures
8+
ms.date: 04/03/2025
9+
uid: blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures
1010
---
11-
# Resolve integrity check failures in ASP.NET Core Blazor WebAssembly apps
11+
# ASP.NET Core Blazor WebAssembly .NET bundle caching and integrity check failures
1212

1313
[!INCLUDE[](~/includes/not-latest-version.md)]
1414

15-
This article explains how to resolve integrity check failures in Blazor WebAssembly apps.
15+
This article explains how Blazor WebAssembly caches the WebAssembly .NET runtime and app bundle and how to diagnose and resolve integrity failures.
16+
17+
When a Blazor WebAssembly app loads in the browser, the app downloads boot resources from the server:
18+
19+
* JavaScript code to bootstrap the app
20+
* .NET runtime and assemblies
21+
* Locale specific data
22+
23+
Except for Blazor's boot resources file (`blazor.boot.json`), WebAssembly .NET runtime and app bundle files are cached on clients. The `blazor.boot.json` file contains a manifest of the files that make up the app that must be downloaded along with a hash of the file's content that's used to detect whether any of the boot resources have changed. Blazor caches downloaded files using the browser [Cache](https://developer.mozilla.org/docs/Web/API/Cache) API.
1624

1725
When Blazor WebAssembly downloads an app's startup files, it instructs the browser to perform integrity checks on the responses. Blazor sends SHA-256 hash values for DLL (`.dll`), WebAssembly (`.wasm`), and other files in the `blazor.boot.json` file, which isn't cached on clients. The file hashes of cached files are compared to the hashes in the `blazor.boot.json` file. For cached files with a matching hash, Blazor uses the cached files. Otherwise, files are requested from the server. After a file is downloaded, its hash is checked again for integrity validation. An error is generated by the browser if any downloaded file's integrity check fails.
1826

aspnetcore/blazor/host-and-deploy/webassembly/github-pages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The GitHub-hosted Ubuntu (latest) server has a version of the .NET SDK pre-insta
6969

7070
The default GitHub Action, which deploys pages, skips deployment of folders starting with underscore, the `_framework` folder for example. To deploy folders starting with underscore, add an empty `.nojekyll` file to the root of the app's repository. Example: [Xref Generator `.nojekyll` file](https://github.com/dotnet/blazor-samples/blob/main/BlazorWebAssemblyXrefGenerator/.nojekyll)
7171

72-
***Perform this step before the first app deployment:*** Git treats JavaScript (JS) files, such as `blazor.webassembly.js`, as text and converts line endings from CRLF (carriage return-line feed) to LF (line feed) in the deployment pipeline. These changes to JS files produce different file hashes than Blazor sends to the client in the `blazor.boot.json` file. The mismatches result in integrity check failures on the client. One approach to solving this problem is to add a `.gitattributes` file with `*.js binary` line before adding the app's assets to the Git branch. The `*.js binary` line configures Git to treat JS files as binary files, which avoids processing the files in the deployment pipeline. The file hashes of the unprocessed files match the entries in the `blazor.boot.json` file, and client-side integrity checks pass. For more information, see <xref:blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching>. Example: [Xref Generator `.gitattributes` file](https://github.com/dotnet/blazor-samples/blob/main/BlazorWebAssemblyXrefGenerator/.gitattributes)
72+
***Perform this step before the first app deployment:*** Git treats JavaScript (JS) files, such as `blazor.webassembly.js`, as text and converts line endings from CRLF (carriage return-line feed) to LF (line feed) in the deployment pipeline. These changes to JS files produce different file hashes than Blazor sends to the client in the `blazor.boot.json` file. The mismatches result in integrity check failures on the client. One approach to solving this problem is to add a `.gitattributes` file with `*.js binary` line before adding the app's assets to the Git branch. The `*.js binary` line configures Git to treat JS files as binary files, which avoids processing the files in the deployment pipeline. The file hashes of the unprocessed files match the entries in the `blazor.boot.json` file, and client-side integrity checks pass. For more information, see <xref:blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures>. Example: [Xref Generator `.gitattributes` file](https://github.com/dotnet/blazor-samples/blob/main/BlazorWebAssemblyXrefGenerator/.gitattributes)
7373

7474
To handle URL rewrites based on [Single Page Apps for GitHub Pages (`rafrex/spa-github-pages` GitHub repository)](https://github.com/rafrex/spa-github-pages):
7575

aspnetcore/blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

aspnetcore/blazor/progressive-web-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,5 +405,5 @@ The [`CarChecker`](https://github.com/SteveSandersonMS/CarChecker) sample app de
405405

406406
## Additional resources
407407

408-
* [Troubleshoot integrity PowerShell script](xref:blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching#troubleshoot-integrity-powershell-script)
408+
* [Troubleshoot integrity PowerShell script](xref:blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures#troubleshoot-integrity-powershell-script)
409409
* [Client-side SignalR cross-origin negotiation for authentication](xref:blazor/fundamentals/signalr#client-side-signalr-cross-origin-negotiation-for-authentication)

aspnetcore/toc.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,8 @@ items:
684684
uid: blazor/host-and-deploy/webassembly/apache
685685
- name: Deploy to GitHub Pages
686686
uid: blazor/host-and-deploy/webassembly/github-pages
687-
- name: Runtime and app bundle caching
688-
uid: blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching
689-
- name: Integrity check failures
690-
uid: blazor/host-and-deploy/webassembly/integrity-check-failures
687+
- name: Bundle caching and integrity check failures
688+
uid: blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures
691689
- name: HTTP caching issues
692690
uid: blazor/host-and-deploy/webassembly/http-caching-issues
693691
- name: Multiple hosted WebAssembly apps

aspnetcore/whats-new/dotnet-AspNetCore.Docs-mod4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Welcome to what's new in the ASP.NET Core docs for April 2024. This article list
1313

1414
### New articles
1515

16-
- <xref:blazor/host-and-deploy/webassembly/runtime-and-app-bundle-caching>
16+
- <xref:blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures>
1717
- <xref:blazor/tooling/webassembly>
1818
- <xref:blazor/security/qrcodes-for-authenticator-apps>
1919
- <xref:blazor/js-interop/javascript-location>

0 commit comments

Comments
 (0)