I created a ASP.Net Core 2.0 with One controller, no problem. Then I added another Controller, then this Exception appears:
InvalidOperationException: The following errors occurred with attribute routing information:
Error 1: Attribute routes with the same name 'Get' must have the same template: Action: 'Patrimonio.Controllers.CategoriaController.Getcc (Patrimonio)' - Template: 'api/Categoria/{id}' Action: 'Patrimonio.Controllers.PatrimonioController.Getac (Patrimonio)' - Template: 'api/Patrimonio/{id}' Microsoft.AspNetCore.Mvc.Internal.ControllerActionDescriptorBuilder.Build(ApplicationModel application)
the first Controller has
// GET: api/Categoria
[Route("api/Categoria")]
public class CategoriaController : Controller
...
[HttpGet]
public IEnumerable<string> Geta()
{
return new string[] { "value1", "value2" };
}
the second has
// GET: api/Patrimonio/5
[Route("api/Patrimonio")]
public class PatrimonioController : Controller
...
[HttpGet("{id}", Name = "Get")]
public string Getac(string id)
{
return "value" + id;
}
Even with the Getac and Getcc, ASP.Net Core complains about same name 'Get' .
How to solve this?