C#C
C#10mo ago
Acetylene

Blazor WebAssembly API Controller

Hi all, I am pretty new in C#. Now, I'm working on a Blazor web project. My project structure is like that:
| MealOrdering (Blazor WebAssembly) ( MealOrdering.Server.Data and MealOrdering.Shared added as dependent projects)
| MealOrdering.Server.Data (Class Library)
| MealOrdering.Shared (Class Library)

I created models in MealOrdering.Server.Data, DTOs in MealOrdering.Shared, services in MealOrdering. Also added AutoMapper package to MealOrdering and created Services/Extensions/ConfigureMappingExtension.cs.
Finally, in MealOrdering, I created a folder which is named Controllers and a API Controller which is named UserController.cs. I added a method for handling GET request.
[HttpGet("Users")]
public async Task<ServiceResponse<List<UserDTO>>> GetUsers()
{
    return new ServiceResponse<List<UserDTO>>
    {
        Value = await userService.GetUsers()
    };
}


However, when I go to https://localhost:44325/api/User/Users, it returns Not Found... What should I do to get users?

Project structure has been attached.

I tried my best so hope it's clear to get help.
image.png
Was this page helpful?