I'm building an ASP.NET Core 5.0 Web API application as I mentioned in the title I have an issue when trying to delete a record from the database; I'm getting an error 405 Method Not Allowed response from HttpDelete request.
PS: I have added services.AddCors() and app.UseCors() with default policy.
This is the delete method code
public bool deleteLivreById(int id)
{
Livre l = _db.Livres.Find(id);
_db.Livres.Remove(l);
_db.SaveChanges();
return true;
}
And this is the HttpDelete method inside the controller
[HttpDelete("{id}/delete")]
public bool deleteLivreById(int id)
{
return _objGererLivre.deleteLivreById(id);
}
Finally this is a picture from console when navigating to HttpDelete Url
Edit: This is full code of my controller
namespace GestionLivre.Controllers
{
[ApiController]
[Route("test")]
public class LivreController : Controller
{
private IGererLivre _objGererLivre;
public LivreController(IGererLivre gererLivre)
{
_objGererLivre = gererLivre;
}
[HttpGet]
public JsonResult getLivres()
{
return Json(_objGererLivre.getLivres());
}
[HttpDelete("{id}/delete")]
public bool deleteLivreById(int id)
{
return _objGererLivre.deleteLivreById(id);
}
}
}



public bool getById([FromRoute]int id)