问题
I have Areas
in application. One area name is Admin
and it has SchoolController
inside its controller folder and Views
inside Views\School folder
.
When I use anchor tag inside Views\School\Index.html
it is not working i.e not generating href attribute but if I place the same tag on layout or any other razor page which is not inside area, it is generating href tag.
Anchor tag is -
<a class="nav-link text-dark" asp-area="Admin" asp-controller="School" asp-action="Index">School</a>
Routing configuration is as -
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "MyArea",
pattern: "{area:exists}/{controller=School}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Account}/{action=SignIn}/{id?}");
});
Anchor tag rendered out side of area pages as <a class="nav-link text-dark" href="/Admin">School</a>
and inside area views as <a class="nav-link text-dark" asp-area="Admin" asp-controller="School" asp-action="Index">School</a>
Can you please guide whats missing?
来源:https://stackoverflow.com/questions/62742151/anchor-tag-helper-withing-area-folder-not-generating-route-area-name-mvc-core-3