I have multiple services that return IResult
and don´t want to use minimal API structure, but I want to use the same return type IResult, but when I use that in the controller it always returns Ok:
Minimal API example that returns 400 Bad request:
app.MapPut("test", async () =>
{
return Results.BadRequest("hello");
});
The classic controller that returns 200 Ok:
[ApiController]
public class TestController : ControllerBase
[HttpPut("test")]
public async Task<IResult> Test()
{
return Results.BadRequest();
}
Is there an easy way to fix this or do I need a mapping function?
I am using .NET 6.