I have a problem in ASP.NET Core 5. When I use asp-area for example like this:
<form asp-area="Admin" asp-controller="User" asp-action="Register">your text
the generated link for the code above is
https://localhost:44300/User/Register?area=Admin
though I want it to go
https://localhost:44300/Admin/User/Register
Am I doing someting wrong? Btw this my route in startup.cs:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "areaRoute",
pattern: "{area}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "areas",
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
}
);
endpoints.MapControllerRoute( name: "areaRoute", pattern: "{area}/{controller=Home}/{action=Index}/{id?}");? The documentation and examples don't seem to regard this part as necessary. Just the last route you've specified ought to do the trick as far as I can see.