1

I have a common navigation menu that I use throughout my mvc 5 application. The home link is defined as follows:

 <a href="@Url.Action("Index", "Home")">
       <i class="fa fa-laptop"></i> 
       <span class="nav-label">Home</span> 
 </a>

The problem is when I navigate to my admin "area", such as to [root]/admin/customers, if I click on the'Home' link it tries to goto "/admin/Home", versus Home in the root.

Question: Do I have to create 2 different menus in order to accomplish this?

klashar
  • 2,519
  • 2
  • 28
  • 38
WebDevGuy2
  • 1,159
  • 1
  • 19
  • 40

1 Answers1

3

You can explicitly tell MVC to not use an any(current) area when building the result of Url.Action call.

<a href="@Url.Action("Index", "Home",new {area=string.Empty})">Home</a>

You can do the same thing when using the Html.ActionLink helper method as well.

@Html.ActionLink("Home","Index","Home",new {area=string.Empty},null)
Shyju
  • 214,206
  • 104
  • 411
  • 497