Home > Mobile >  ASP.NET MVC core 5 _layout menu item changes links depending on the subpage
ASP.NET MVC core 5 _layout menu item changes links depending on the subpage

Time:12-01

I'm not sure why the created link isn't consistent. In my _layout.cshtml shared view I have this:

<a  
   asp-area="" 
   asp-controller="Repairs"
   uiactions="Index">Repairs</a>

This creates

<a  uiactions="Index" href="/Repairs">Repairs</a>

when clicked on from a page other than a Repairs/Detail page that can be chosen from within the Index page. However when I'm in the Repairs/Detail partial page, the _layout entry now creates this:

<a  uiactions="Index" href="/Repairs/Detail">Repairs</a>

How do I write my _layout entry so that it always loads Index.cshtml?

CodePudding user response:

You can try the follow code. Change uiactions="Index" into asp-action="Index"

 <li >
 <a  asp-area="" asp-controller="Repairs" asp-action="Index">Repairs</a>
 </li>

  • Related