© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
22 replies
hapless.dev

✅ controller endpoint gets 404 when hit

hi everyone, im trying to make an auth web api, i managed to create an AuthService and whatnot, and my controller has only two routes, im trying to implement the /register and swagger gets it fine, but as soon as i execute the request i get 404d, why is that? i tried curl and still, could someone give me a hand?

// Controllers/AuthAPIController.cs
using Microsoft.AspNetCore.Mvc;

using Services.AuthAPI.Models.DTO;
using Services.AuthAPI.Service.IService;

namespace Services.AuthAPI.Controllers {
    [Route("api/auth")]
    [ApiController]
    public class AuthAPIController : ControllerBase {
        private readonly IAuthService _authService;
        protected ResponseDTO _res;

        public AuthAPIController(IAuthService authService) {
            _authService = authService;
            _res = new();
        }

        [HttpPost("register")]
        public async Task<IActionResult> Register([FromBody] RegistrationRequestDTO model) {
            var errorMsg = await _authService.Register(model);

            if (!string.IsNullOrEmpty(errorMsg)) {
                _res.IsSuccess = false;
                _res.Message = errorMsg;

                return BadRequest(_res);
            }

            return Ok(_res);
        }

        [HttpPost("login")]
        public async Task<IActionResult> Login() {
            return Ok();
        }
    }
}
// Controllers/AuthAPIController.cs
using Microsoft.AspNetCore.Mvc;

using Services.AuthAPI.Models.DTO;
using Services.AuthAPI.Service.IService;

namespace Services.AuthAPI.Controllers {
    [Route("api/auth")]
    [ApiController]
    public class AuthAPIController : ControllerBase {
        private readonly IAuthService _authService;
        protected ResponseDTO _res;

        public AuthAPIController(IAuthService authService) {
            _authService = authService;
            _res = new();
        }

        [HttpPost("register")]
        public async Task<IActionResult> Register([FromBody] RegistrationRequestDTO model) {
            var errorMsg = await _authService.Register(model);

            if (!string.IsNullOrEmpty(errorMsg)) {
                _res.IsSuccess = false;
                _res.Message = errorMsg;

                return BadRequest(_res);
            }

            return Ok(_res);
        }

        [HttpPost("login")]
        public async Task<IActionResult> Login() {
            return Ok();
        }
    }
}
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Error about anti-forgery on production when try hit api endpoint
C#CC# / help
3y ago
Game Over screen when obstacle hit
C#CC# / help
2y ago
when connecting database 404 not found error
C#CC# / help
2y ago
HTTP Request throws exception when invoking controller
C#CC# / help
4y ago