Depending on how you are hosting Blazor—through Server or WebAssembly models—the implementation is quite different. Visual Studio has support for creating Blazor Server or WebAssembly projects, as can be seen in the following screenshot:
Next, let's see how this works, in the sections ahead.
Implementing Blazor Server
Blazor Server also has the dotnet tool, which can be used as follows:
dotnet new blazorserver
This will create a sample Blazor project in Server mode that communicates to a representational state transfer (REST) web API. This will be the same as if generating a Blazor project from Visual Studio and checking the ASP.NET Core hosted checkbox. If you have a look at the generated project, you will notice that, first, Blazor services need to be registered to the dependency injection (DI) framework, in ConfigureServices, as follows:
services...