The ASP.NET Core MVC tag helpers aren’t acting like they used to. When I write something like this:
<a asp-area="Admin" asp-controller="Home" asp-action="Index"></a>
The link redirects me to ~/Home/Index?area=Admin
instead of ~/Admin/Home/Index
(which can be simplified to ~/Admin
).
I have decorated the controllers in that area with [Area("Admin")]
, the tag helpers are imported in my _ViewImports
inside ~/Areas/Admin/Views
folder and my routing configuration looks like this:
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapControllerRoute(
name: "areaRoute",
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
I can’t figure out what I did wrong. I didn’t have this problem before.