I have a controller that gets a route attribute:
[Route("api/v1/Admin/Keys")]
public class AdminController : Controller
{}
My Webproject has the following routes:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Admin}/{action=GetAllKeys}/{id?}");
});
Error:
This localhost page can’t be found No web page was found for the web address: http://localhost:60907/
When trying to go call a method on the controller which is also routed I keep getting the same.
If I remove the route attribute from the controller then this starts to work but I do not get the desired route.
What am I doing wrong?
EDIT:
Method that I am calling in the browser:
[HttpGet]
[Route("GetAllKeys")]
public async Task<IActionResult> GetAllKeys()
{
var data = await _manager.GetAllKeyTypes();
return Ok(data);
}
error:
This localhost page can’t be found No web page was found for the web address: http://localhost:60907/
EDIT2:
Now when removing the global route and just using the:
[HttpGet("GetAllKeys")]
And using the following url: http://localhost:60907/GetAllKeys
This works but again it is not desiered