This is an article on ASP.NET Core routing: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing
It is straight forward. I can either specify a route like this:
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
Or I can mark my controllers and actions with attributes like this:
[Route("api/[controller]")]
public class TestController : Controller
{
[HttpGet("{id}")]
public async Task<string> Get(string id)
{
return "test";
}
}
But, I tried putting a controller in an external library with attributes, and referenced that assembly from my main service, and when I punch the Url in, the call is not routed to the controller. I'm guessing I need to tell ASP.NET Core which assemblies to scan through, but I don't know how. I am using this url BTW: http://localhost:5000/api/test/a.