0

I have this code structure, a Home controller at root level and another Home controller at Area level. One of the answers on SO helped me to solve the Multiple controller name error but what I am not getting is why the root actionlinks are appended with Area name once Area views has been visited.

enter image description here

_Layout.cshtml

  <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li>@Html.ActionLink("Home", "Index", "Home")</li>
                        <li>@Html.ActionLink("About", "About", "Home")</li>
                        <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                        <li>@Html.ActionLink("AuthorCF", "Index", "AuthorCFs")</li>

                        @*Area*@
                        <li>@Html.ActionLink("Service Requests", "Home", "ServiceRequests")</li>

                    </ul>
                </div>

When I click on Service Requests I am able to visit Service request Index page But when I hover over About/Contact link, I see "http://localhost:62864/ServiceRequests/Home/Contact" , why the ServiceRequests is getting appended ?

Please let me know if I need to ask this more clearly.

Akshay
  • 1,412
  • 2
  • 17
  • 51
  • `@Html.ActionLink("Home", "Index", "Home", new { area = "" })` –  Mar 20 '18 at 10:36
  • This url says "http://localhost:62864/ServiceRequests/Home?Length=4" and on click it stays on same Area page. – Akshay Mar 20 '18 at 10:40
  • 1
    Sorry, forgot t include the necessary 5th argument - `@Html.ActionLink("Home", "Index", "Home", new { area = "" }, null)` –  Mar 20 '18 at 10:41
  • Thanks for help Stephen! That solved. – Akshay Mar 20 '18 at 10:43
  • 1
    Your might find [this answer](https://stackoverflow.com/questions/34525244/why-mvc-keeps-route-values-in-url-without-passing-them-directly/34525675#34525675) and its links useful to better understand the behavior –  Mar 20 '18 at 10:48

0 Answers0