Add query string to dotnet.js to fix Blazor displaying blank page after framework upgrade #56054
Labels
area-blazor
Includes: Blazor, Razor Components
design-proposal
This issue represents a design proposal for a different issue, linked in the description
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
question
Status: Resolved
Summary
In production environments client browsers will cache dotnet.js and blazor.web.js files. These files do not currently have any query strings appended which means they are not reloaded when a newer framework version is deployed. This results in a blank/white screen being presented to users with no clear indication why.
Motivation and goals
After updating a solution to the latest version with slightly newer dotnet will cause users to encounter issues with browser caching the dotnet.js file which won't get reloaded. This results in a blank/white screen until the cache expires or is refreshed (eg: Ctrl+F5)
In scope
All files underneath the _framework/ path should have this applied to them if they are loaded by blazor.webassembly.js.
Out of scope
Files referenced within the .razor files directly should be out of scope for example blazor.web.js. As Users can specify this as <script src="_framework/blazor.web.js?v=8.0.6"></script> but should ideally be dynamically assigned.
The base template should be updated to have something similar.
Risks / unknowns
Security concern as the reference directly exposes the version which might allow for targeted attacks.
How can the version be automatically assigned to prevent rework in the future?
Examples
let t="_framework/dotnet.js?v=8.0.6";if(e.loadBootResource){const n="dotnetjs",r=e.loadBootResource(n,"dotnet.js?v=8.0.6",t,"","js-module-dotnet");
The text was updated successfully, but these errors were encountered: