title: How to fix HttpErrorResponse 404 Not found
body: <p>I am getting error message on web console, it says "Http failure response for <a href="http://localhost:5000/api/authregister" rel="nofollow noreferrer">http://localhost:5000/api/authregister</a>: 404 Not Found". I tried looking for solutions online, but it did not help. How do I fix this issue?</p>
  
  <p><img src="https://udemy-images.s3.amazonaws.com/redactor/raw/2019-05-08_22-25-50-bb57d7b41abf0188961156d430db2a0e.PNG" alt="pic1"></p>
  
  <p>I tried to see if Postman worked with "GET" and it did work, however on "POST" it will not update database and get no response. </p>
  
  <p><img src="https://udemy-images.s3.amazonaws.com/redactor/raw/2019-05-08_22-27-25-ff88123dc5b97675d540044a6272a746.PNG" alt="pic2"></p>
  
  <p>I checked database for update result and nothing has changed, I only have 2 username and passwords there: </p>
  
  <p><img src="https://udemy-images.s3.amazonaws.com/redactor/raw/2019-05-08_22-29-29-9418d04194a4c8c71ebb85f38b3ad1dc.PNG" alt="pic3"></p>
  
  <p><strong>UPDATE:</strong> I found the reason why I was getting the this ip address: </p>
  
  <blockquote>
    <p><a href="http://localhost:5000/api/authregister" rel="nofollow noreferrer">http://localhost:5000/api/authregister</a></p>
  </blockquote>
  
  <p>On baseUrl, I was missing a '/' on <strong>auth.service.ts</strong>, however I am now getting "Http failure response for <a href="http://localhost:5000/api/auth/register" rel="nofollow noreferrer">http://localhost:5000/api/auth/register</a>: 400 Bad Request". Here is <strong>auth.service.ts</strong>:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import {map} from'rxjs/operators';
  
  @Injectable({ //inject to service
    providedIn: 'root'
  })
  export class AuthService {
    baseUrl = 'http://localhost:5000/api/auth/'; //I added a '/' to the end
  
  constructor(private http: HttpClient) { }
  
  login(model: any) {
    return this.http.post(this.baseUrl + 'login', model)
    .pipe(
      map((response: any) =&gt; {
        const user = response;
        if (user) {
          localStorage.setItem('token', user.token);
        }
      })
    )
  }
  
  register(model: any) { //need authservice in register component constructor
    return this.http.post(this.baseUrl + 'register', model);
    //return this.http.post(this.baseUrl + 'auth/register', model);
  }
  
  
  }
  </code></pre>
  
  <p>Here is AuthController.cs</p>
  
  <pre><code>using System;
  using System.IdentityModel.Tokens.Jwt;
  using System.Security.Claims;
  using System.Text;
  using System.Threading.Tasks;
  using DatingApp.API.Data;
  using DatingApp.API.Dtos;
  using DatingApp.API.Models;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Configuration;
  using Microsoft.IdentityModel.Tokens; //Symmetric Security Keys
  
  namespace DatingApp.API.Controllers
  {
  [Route("api/[controller]")]
  [ApiController]
  public class AuthController : ControllerBase
  {
      private readonly IAuthRepository _repo;
      private readonly IConfiguration _config;
      public AuthController(IAuthRepository repo, IConfiguration config)
      {
          _config = config;
          _repo = repo;
      }
  
      [HttpPost("register")]
      public async Task&lt;IActionResult&gt; Register(UserForRegisterDto userForRegisterDto) //get username and password, [FromBody] gives hint where info is
      {
          userForRegisterDto.Username = userForRegisterDto.Username.ToLower(); //make username lowercase
  
          if (await _repo.UserExists(userForRegisterDto.Username)) //check if User exist
              return BadRequest("Username already exist"); //BadRequist requires ControllerBase
  
          var userToCreate = new User
          {
              Username = userForRegisterDto.Username //APIModels
          };
  
          var createdUser = await _repo.Register(userToCreate, userForRegisterDto.Password);
  
          return StatusCode(201);
      }
  
      [HttpPost("login")]
      public async Task&lt;IActionResult&gt; Login(UserForLoginDto userForLoginDto)
      {
          //throw new Exception("Computer says no!");
  
          var userFromRepo = await _repo.Login(userForLoginDto.Username.ToLower(), userForLoginDto.Password);
  
          if (userFromRepo == null)
              return Unauthorized();
  
          var claims = new[]
          {
              new Claim(ClaimTypes.NameIdentifier, userFromRepo.Id.ToString()), //token claims Id
              new Claim(ClaimTypes.Name, userFromRepo.Username) //token claims username
          };
  
          var key = new SymmetricSecurityKey(Encoding.UTF8
          .GetBytes(_config.GetSection("AppSettings:Token").Value)); //MUST set TOKEN in appsettings.json
  
          var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);
  
          var tokenDescriptor = new SecurityTokenDescriptor
          {
              Subject = new ClaimsIdentity(claims),
              Expires = DateTime.Now.AddDays(1),
              SigningCredentials = creds
          };
  
          var tokenHandler = new JwtSecurityTokenHandler(); //to make token
  
          var token = tokenHandler.CreateToken(tokenDescriptor);
  
          return Ok(new {
              token = tokenHandler.WriteToken(token)
          });
      }
  
  
  }
  }
  </code></pre>