I'm trying to get a CRUD page for usermanagement in a Blazor Server environment. I tried the following code:
The controller:
[HttpGet]
public async Task<ActionResult<IEnumerable<ApplicationUser>>> getUsers()
{
return _context.Users.ToList();
}
The Razor Page:
@page "/administration/"
@inject HttpClient httpClient
@code {
protected override async Task OnInitializedAsync()
{
var users = await httpClient.GetFromJsonAsync<List<ApplicationUser>>
("api/AdministrationController");
}
}
The problem is that ApplicationUser is not recognized within the Razor view. I tried injecting Microsoft.AspNetCore.Identity but this is also not available within the Razor View on client side.
How do I get all the users in a razor view with use of a controller?