This is a simple question and I'm just asking out of curiosity. I've set up endpoint routing to area as such:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "areas",
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
Here is the controller for the area home page:
[Area("mynewarea")]
[Route("mynewarea/[controller]/[action]")]
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.me = "hello world";
return View();
}
}
Here is the tag helper code in the view:
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
<a class="nav-link text-dark" asp-area="mynewarea" asp-controller="Home" asp-action="Index">mynewarea</a>
This all totally works great but not consistently as I would expect. For example, if I put this in the URL
https://localhost/
it works as expected and I get to the home page. But if I put this in the URL
https://localhost/mynewarea
I get a 404.
However if I put this in the URL
https://localhost/mynewarea/Home/Index
I get my page as expected.
was running aspnetcore v3.1.0
when upgraded to current v3.1.1 problem went away