Live Chat Icon For mobile
Live Chat Icon

How do I add a Blazor WebAssembly project to an existing ASP.NET Core application?

Platform: Blazor| Category : General, WebAssembly

Follow these steps to add a Blazor WebAssembly project to an existing ASP.NET Core application:

  1. Create a ASP.NET Core application and Blazor WebAssembly application separately.

  2. Install the Microsoft.AspNetCore.Components.WebAssembly.Server NuGet package in the ASP.NET Core application and add the Blazor WebAssembly application project reference to the ASP.NET Core application.

    <Project Sdk="Microsoft.NET.Sdk.Web">
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.0" />
        <ProjectReference Include="..{Your Blazor App Path}" />

  3. Add the following configurations the Program.cs file in the ASP.NET Core app to include Blazor WebAssembly.

    if (!app.Environment.IsDevelopment())
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see

    //app.MapRazorPages(); // Remove this line.
  4. To avoid conflicts during publishing between WebAssembly and ASP.NET Core applications, it is necessary to delete the favicon.ico file. By default, both projects create a favicon.ico file, which can lead to conflicts. To resolve this, remove one of the favicon.ico files from the project.

Refer to this link for more information. 

View Sample in GitHub 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.