Creating Blazor components
In this section, we will take a closer look at how to consume the gRPC services in the Blazor WebAssembly application. But we have not yet tested that our implementation is working.
Start by simply building the solution using Ctrl + Shift + B. The solution should be built without any errors. If you see errors in your program, check that you follow all the steps correctly, or download the demo project from the GitHub folder (ch5\01_demo_implementation
) to start with clean code.
First, we should test that our gRPC service is working correctly. Open the _Imports.razor
file in MediaLibrary.Client and add using AutoMapper
to the end of the file.
Next, open the Pages\PersonList.razor
file and add the following directives to the top of the file, after the @page
directive:
@using MediaLibrary.Shared.Model @inject IMapper mapper @inject MediaLibrary.Contracts.PersonContract .PersonContractClient client
The preceding code imports a namespace...