Using the basic services
In this section, I will show you how to use some fundamental services in Blazor applications. As you will see, they are almost the same as the server-side services that we covered in earlier chapters. Let's start with the authorization service.
Authorizing the users
We typically use authorization in Blazor applications to hide/disable some pages, components, and functionalities on the user interface. While the server always checks the same authorization rules for security, client-side authorization checks provide a better user experience.
IAuthorizationService
is used to programmatically check permissions/policies, as on the server side. You can inject and use its methods, as shown in the following example:
public partial class Index { protected override async Task OnInitializedAsync() { if (await AuthorizationService ...