I need to add Blazor Web Assembly project to an ASP.NET Core 6 application.
I did as described in this article How to integrate Blazor application
- Removed
builder.RootComponents.Add<App>("#app");
fromProgram
(Blazor) - Added Blazor project to ASP.NET Core project as reference
- Installed
Microsoft.AspNetCore.Components.WebAssembly.Server
package in the ASP.NET Core app. The version is 6.0.32. - Added
app.UseWebAssemblyDebugging();app.UseBlazorFrameworkFiles(); app.MapFallbackToFile("index.html");
to Startup in ASP.NET Core - Added
<script src="_framework/blazor.webassembly.js"></script>
to_Layout.cshtml
in ASP.NET Core - Added Blazor component to view:
<component type="typeof(Counter)" render-mode="WebAssemblyPrerendered" />
.
The component is displayed on the page (view) but when I click button nothing happens (must be counter increased).
Before integrating Blazor Web Assembly project I used Blazor Server in my ASP.NET Core application. But before new update I removed it and all its setup statements (like services.AddServerSideBlazor();).
What can be wrong?
Thanks.
2
I created new ASP.NET Core .NET 6 application and integrated new Blazor WebAssembly Standalone App .NET 6 as described in this article. All works fine. I could add Counter component to view and button click increases counter.