Please make sure that the Controller is added in the Program.cs file.
builder.Services.AddControllers();