Building components using Blazor Server
In this section, we will build a component to list, create, and edit customers in the Northwind database.
We will build it over several steps:
- Make a Blazor Server component that renders the name of a country set as a parameter.
- Make it work as a routable page as well as a component.
- Implement the functionality to perform CRUD operations on customers in a database.
- Refactor the component to work with both Blazor Server and Blazor WebAssembly.
Defining and testing a simple Blazor Server component
We will add the new component to the existing Blazor Server project:
- In the
Northwind.BlazorServer
project (not theNorthwind.BlazorWasm.Server
project), in thePages
folder, add a new file namedCustomers.razor
. In Visual Studio, the project item template is named Razor Component.
Good Practice: Component filenames must start with an uppercase letter, or you will have compile...