Blazor WebAssembly + ABP 10.0.2 + .NET 10 Preview Release Compatibility Issues Record
Conclusion: Currently, using .NET 10 + ABP 10.0.2 to publish Blazor WASM will encounter framework-level issues such as script loading and Service Worker caching. In the short term, it is more recommended to use the stable version of .NET 8 + ABP 8, or adopt a small number of manual script references as a temporary solution in the current project.
1. Phenomenon: Normal in Development Mode, White Screen in Published Mode
- Development mode (
dotnet run/ IDE startup):- Blazor WebAssembly can be loaded normally.
- Login, OIDC, and ABP components all work normally.
- Published mode (started from
bin/Release/net10.0/publishafterdotnet publish):- The page HTML can return 200.
- Most of the static resources (
global.css,global.js,dotnet.js, etc.) can return 200. - But the front end does not render content in the end, and an exception appears in the console.
Typical error logs:
- 404 appears multiple times in the backend log:
_framework/WHS.Blazor.Client.jqrq8onpr6.wasm404.service-worker-assets.js404.
- Front-end console error:
Could not find 'AuthenticationService.init' ('AuthenticationService' was undefined).- Occurs in the
callEntryPointstage ofblazor.web.js.
2. Old Resource Caching Issue Caused by Service Worker
Blazor PWA will by default:
- Load
service-worker-assets.jsthroughservice-worker.published.js. - Cache resources such as
blazor.boot.json, wasm, dll, css, js according toassetsManifest.
The problem encountered with the combination of .NET 10 + ABP 10.0.2 is:
- After the first release, Service Worker will cache an old
blazor.boot.jsonand wasm hash. - When the code is modified and published again, even if the new wasm file is already on the server:
- The browser still preferentially takes the old version of
blazor.boot.jsonfrom the SW cache. - As a result, the front end will request a non-existent
_framework/WHS.Blazor.Client.<old>.wasm, and the server returns 404.
- The browser still preferentially takes the old version of
Temporary solution:
- In
App.razor, make a special judgment for localhost and unregister all registered Service Workers at startup:
|
|
- For the production environment (non-localhost),
service-worker.published.jsis still registered according to normal logic, retaining PWA capabilities.
3. ABP Core JS Not Injected Correctly
ABP Blazor relies on a set of core JS files, such as:
_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/authentication-state-listener.js
According to ABP’s design, these scripts are usually:
AbpBundlingOptions+BlazorWebAssemblyStandardBundles.Scripts.Global;<!--ABP:Scripts-->+app.MapAbpStaticAssets();
Automatically injected into the page.
In the new “Razor Components + Interactive WebAssembly” mode of .NET 10 + ABP 10.0.2 + Blazor, it is actually observed that:
- In the published mode, when
blazor.web.jsstarts, the above scripts may not have been loaded yet. - Result: The
AuthenticationServiceorabpobject isundefined, triggering an error thatAuthenticationService.initcannot be found.
Temporary solution: Manually hardcode core script references and place them before blazor.web.js:
|
|
This ensures that:
- When
blazor.web.jscalls the .NET entry point, the relevant JS APIs are already available inwindow.
4. Why Manually Referencing Scripts is a “Temporary Solution”
Advantages:
- Can quickly bypass the automatic Bundling/injection problem of the current version and make the application available in the published mode.
- It is easier to troubleshoot and control the script loading order.
Disadvantages:
- Lose the benefits of automatic merging, compression, and version hashing brought by the ABP Bundling system.
- After ABP or .NET is upgraded, if the script path or file name changes, you need to manually maintain these
<script>. - May be duplicated with the content injected by
<!--ABP:Scripts-->(be careful not to load the same script twice).
Therefore, it is recommended to explicitly mark it as “compatibility fix / TODO” in the code, and it can be cleaned up after the framework is fixed:
|
|
5. Summary
​ ABP 10.0.2 building Blazor WebAssembly does have a series of script and cache compatibility issues in the published mode. Before the official version is fully polished, “considering reverting to the .NET 8 stable stack” is a more pragmatic choice in engineering.