Anchor tag helper withing area folder not generating route area name MVC Core 3.1

橙三吉。 提交于 2020-07-10 07:00:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!