0

I would like to create a Blazor Web App that first renders components using SSR until the Wasm components can be downloaded then future requests should render the Wasm component.

My application seems to be rendering everything using SSR and it is failing to download the Wasm components

blazor.web.js:1
GET http://localhost:5029/_framework/dotnet.js
net::ERR_ABORTED 404 (Not Found))

Here is my current configuration:

App.razor:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <base href="/" /> <link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" /> <link rel="stylesheet" href="@Assets["app.css"]" /> <link rel="stylesheet" href="@Assets["SampleApp.styles.css"]" /> <ImportMap /> <link rel="icon" type="image/png" href="favicon.png" /> <HeadOutlet @rendermode="InteractiveAuto" /> </head> <body> <Routes @rendermode="InteractiveAuto" /> <script src="_framework/blazor.web.js"></script> </body> </html> 

Program.cs:

var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error", createScopeForErrors: true); app.UseHsts(); } app.UseHttpsRedirection(); // app.UseBlazorFrameworkFiles(); // app.UseStaticFiles(); app.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents<App>() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode(); app.Run(); 

Please note that I have tried with and without app.UseStaticFiles(); with no luck. Am I missing something to include the Wasm components, or do I need to create a .Client project for my Wasm components?

1
  • Do you want Server-Side Rendered or Blazor Server rendered on initial load? They are different. SSR is static pages, Blazor Server are interactive pages. Commented Aug 19 at 13:23

1 Answer 1

2

or do I need to create a .Client project for my wasm components?

Yes, you do need a Client project. Your server app won't run in the browser.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.