Help! My swagger controllers all return a 404 in .NET 6

Wouter
3 min readApr 12, 2022

I was playing around with .NET 6 last week and I was creating a new REST API using swagger. Nothing too complex right? Installing some nuget packages and changing some code in the startup file. It went very smoothly and everything worked fine: my app didn’t have any build errors and the swagger file loaded.

However when I tried to call an HTTP Post endpoint I got a 404 not found. And this was the case for every endpoint.

The setup

My controller looked like this:

[ApiController][Route("[controller]")]public class MemberController : ControllerBase{private readonly IMemberRepository _memberRepository;public MemberController(IMemberRepository memberRepository){_memberRepository = memberRepository;}[HttpPost][ProducesResponseType(StatusCodes.Status201Created)]public async Task<IActionResult>…

--

--