I am trying to set up a API for my MVC web app that will have a lot of routes but much of the same part for each one. Basically a CRUD for each area. I am also setting it up t
Both your routes are named the same, this cannot work in ASP.NET Core MVC.
I'm not talking about the methods naming, but about routes naming. You called both your routes with the same identifier Name = "delete"
inside the HttpPost
attribute. Route names in MVC uniquely identifies a route template.
From what I can see you do not really need to identify your routes, but only to distinguish different URIs. For this reason you may freely remove the Name
property of HttpPost
attribute on your action methods. This should be enough for ASP.NET Core router to match your action methods.
If you, instead, what to revert using only attribute routing you better change your controller to the following:
// other code omitted for clarity
[Route("aim/v1/contacts/")]
public class aimContactsController : Controller
{
[HttpPost("delete/{id}")]
public IActionResult delete(string id)
{
// omitted ...
}
}