im using .net core 3.1.1
in mvc area when i use asp-action like this
<a asp-action="Index2">Index2</a>
do not generate link correctly (missed area name )
generate link : http://localhost:49770/Home/Index2
but correct link is http://localhost:49770/admin/Home/Index2
i using endpoint routing
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
"area",
"Admin",
"{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
});
but when is use older routing (usemvc) asp-action generate link correctly
http://localhost:49770/admin/Home/Index2
app.UseMvc(routes =>
{
routes.MapRoute(
name : "areas",
template : "{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
});
anyone can help me with endpoint routing use asp-action thanks
asp-area
tag helper in conjunction withasp-action
to specify the target area (source). – Jeremy Caney