Blazor Server
Learn the structure of the Blazor Server project template.
We'll cover the following...
The Blazor Server has a different hosting model from Blazor WebAssembly. Therefore, its application project structure is also different. We have an example of a Blazor Server project template in the code widget below.
<Router AppAssembly="@typeof(App).Assembly"> <Found Context="routeData"> <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> <NotFound> <PageTitle>Not found</PageTitle> <LayoutView Layout="@typeof(MainLayout)"> <p role="alert">Sorry, there's nothing at this address.</p> </LayoutView> </NotFound> </Router>
Blazor Server project setup
Project file and dependencies
In the setup above, we have a project called Blazor
. The structure of the Blazor.csproj
file is as follows:
Press + to interact
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net7.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup></Project>
As we can see, a Blazor Server project doesn’t rely on additional dependencies. It is just a typical ASP.NET Core application. We are only using inbuilt components of ASP.NET Core.