Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: https://localhost:7169/_framework/dotnet.js

1.3k views Asked by At

Good day

I am working on a new blazor app, .NET 8 RC 1 and while the app seems to work locally as I am debugging and making changes, this error pops up in the developer tools (browser) console:

What is it, and how do I fix this?

GET https://localhost:7169/_framework/dotnet.js net::ERR_ABORTED 404 (Not Found)

Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: https://localhost:7169/_framework/dotnet.js

enter image description here

3

There are 3 answers

1
Patrizio Ricciardello On

I recently encountered the same error and discovered that the cause in my case was related to the ASP.NET Core Server Project. Specifically, the issue was with the following line (Program.cs):

host.UseBlazorFrameworkFiles();

Interestingly, this line is not included in the Blazor Web App Template, which led me to believe that it might no longer be valid.

The error became apparent when I was updating from .NET 7 to .NET 8. Dan Roth, a prominent figure in the .NET community, has also mentioned similar issues when upgrading projects. You can find more details on his GitHub page: Dan Roth's Net8BlazorWebAssembly.

If you're facing similar problems after upgrading, I recommend following Dan Roth's upgrade advice."

0
Simon Bartlett On

I ran into this exact same issue, I resolved it by moving my WebAssembly components to a new BlazorWebAssembly project.

Use this command to generate an example project with working WebAssembly render mode, and compare the differences to what you have:

dotnet new blazor -o BlazorApp -int Auto

A quick summary of the changes in the generated project:

  • AdditionalAssemblies is Routes.razor
  • AddAdditionalAssemblies being used in Program.cs
  • A Client WebAssembly project
4
SuperBlazor On

This occurs because the client (browser) has not been able to download the Javascript module dotnet.js, this library is used to create and start the .NET WebAssembly runtime. As you know, in a Blazor.Net 8 project it is possible through the @attribute to choose different operating modes for your page/component, examples: [RenderModeWebAssembly], [RenderModeAuto], [RenderModeServer] for example if you use the latter this library will not be necessary since Blazor the Framework uses this library blazor.web.js