How can I set up a default routing if the controller is inside a subfolder? Currently, running the code shown here, I get an error
localhost page can't be found
My folder structure is set up like this:
Project Name
> API
> Controllers
> ProductsController
ProductsController
[Area("API")]
[Route("products")]
[ApiController]
public class ProductsController : ControllerBase
{
[HttpGet]
[Route("list")]
public ActionResult<List<Product>> GetProductsList()
{
var products = _context.Products.ToList();
return Ok(products);
}
}
Startup.cs
app.UseEndpoints(endpoints =>
{
endpoints.MapAreaControllerRoute(
name: "MyProducts",
areaName: "API",
pattern: "{controller=products}/{action=list}/{id?}");
});