Simple Steps to Integrate a Blazor WebAssembly Project with an Existing ASP.NET Core Application
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (168).NET Core  (29).NET MAUI  (150)Angular  (95)ASP.NET  (51)ASP.NET Core  (81)ASP.NET MVC  (89)Azure  (40)Blazor  (186)BoldSign  (11)DocIO  (24)Essential JS 2  (101)Essential Studio  (194)File Formats  (50)Flutter  (127)JavaScript  (214)Microsoft  (118)PDF  (77)Python  (1)React  (87)Streamlit  (1)Succinctly series  (130)Syncfusion  (758)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (46)Windows Forms  (59)WinUI  (64)WPF  (147)Xamarin  (160)XlsIO  (28)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (134)Chart  (92)Cloud  (14)Company  (445)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (61)Development  (536)Doc  (7)DockingManager  (1)eBook  (98)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (29)Extensions  (21)File Manager  (6)Gantt  (17)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (422)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (36)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (11)Scheduler  (48)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (29)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (110)UI  (292)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (26)Visual Studio Code  (17)Web  (492)What's new  (272)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Simple Steps to Integrate a Blazor WebAssembly Project with an Existing ASP.NET Core Application

Simple Steps to Integrate a Blazor WebAssembly Project with an Existing ASP.NET Core Application

This blog provides a walk-through about how to integrate a Blazor WebAssembly project into an existing ASP.NET Core application with Syncfusion Blazor Query Builder. This blog will be helpful if you have an ASP.NET Core application and are planning to upgrade it into an ASP.NET Core WebAssembly project. This will avoid the complete redevelopment of the ASP.NET Core application to support Blazor.

What is Blazor?

Blazor is a single-page application framework that is used to build websites with HTML, CSS, and C# code. It creates rich interactive UIs using C# instead of JavaScript, and it can execute Razor views on the server as well as the client to present HTML to the browser.

What is Blazor WebAssembly and how does it work?

Blazor WebAssembly is a single-page application framework for building interactive client-side web apps with .NET, and it works in all web browsers. .NET WebAssembly-related code and its dependencies, such as C# and Razor files, are compiled into .NET assemblies, which are downloaded and executed directly on the browser. It is maintained as a bytecode format for fast download and maximum execution speed, and it can access the features of the browser via JavaScript, a capability called JavaScript interoperability. To learn about the pros and cons of using JavaScript interop in Blazor, refer to this article.

How to create the Blazor WebAssembly project

A Blazor WebAssembly (client-side) project can be created by following these steps.

Step #1: Download and install Visual Studio 2022

Download and install the latest version of Visual Studio 2022 with the ASP.NET and web development workloads.

If you don’t know how to install the application or stumble on a problem, you can go through the installation documentation here.

Step #2: Create a new project

After installation, open Visual Studio and select Create a new project.

Visual Studio Start Window
Visual Studio Start Window

Step #3: Select the Blazor WebAssembly app template

Select Blazor WebAssembly App from the template list and then click Next.

Template List in Visual Studio
Template List in Visual Studio

Step #4: Configure the project

At this step, the project configuration window will open. Here, we provide the required details such as project name and location, and then click the Next button.

Configuration Menu
Configuration Menu

Step #5: Create the Blazor WebAssembly application

Now, select a target framework of your choice and click Create to create the WebAssembly application.

Additional Information Menu
Additional Information Menu

The created Blazor application will look similar to the one in the following screenshot.

Created Blazor Application
Created Blazor Application

Adding Syncfusion Query Builder to the WebAssembly project

To create a Blazor query builder application, configure the Syncfusion NuGet package by referring to this documentation: Getting Started with Blazor Query Builder Component.

Add the Blazor WebAssembly project to an existing ASP.NET Core application

Integrate the Blazor WebAssembly project with an existing ASP.NET Core application by following the steps below.

Step #1: Open an existing ASP.NET Core application in Visual Studio.

ASP.NET Core Application in Visual Studio
ASP.NET Core Application in Visual Studio

Step # 2: Open the .csproj file of the ASP.NET Core application and add the following configuration code to integrate the Blazor WebAssembly project to the application.

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" />
    <ProjectReference Include="..\..\BlazorWasmApp\BlazorWasmApp\BlazorWasmApp.csproj" />

Step #3: Add the Blazor WebAssembly project into the ASP.NET Core solution by right-clicking on the application’s solution as shown in the screenshot below.

ASP.NET Core Solution Panel in Visual Studio
ASP.NET Core Solution Panel in Visual Studio

Step # 4: Open the Program.cs file and add the highlighted code lines below.

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
if (app.Environment.IsDevelopment())
//app.MapRazorPages(); // Remove this line.

Step #5: Delete the favicon.ico file. The favicon.ico file is created by default in both the WebAssembly and ASP.NET Core applications. To avoid conflict between these two projects while publishing, we must remove one of the files. We can achieve this as illustrated in the screenshot below.

ASP.NET Core Application Window
ASP.NET Core Application Window

Step #6: Run the sample. The output will be like the screenshot below.

Blazor WebAssembly Application in ASP.NET Core Application
Blazor WebAssembly Application in ASP.NET Core Application


For the complete source code, refer to the integrate Blazor WebAssembly in ASP.NET Core app GitHub repository.


We hope this blog post on how to add a Blazor WebAssembly project to an existing ASP.NET Core application was helpful. If you want to see what else Syncfusion has to offer for ASP.NET Core developers, we hope you’ll try out Essential Studio for ASP.NET Core.

Please let us know if you have any queries or need clarification in the comments section below. You may also get in touch with us via our support forum, support portal, or feedback portal. We are delighted to help you!

Related blogs

If you like this post, we think you will enjoy the following ASP.NET Core articles as well:


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top