Arepa
Arepa

Reputation: 25

Routing problems from area to layout MVC 5

I have a routing problem from my "Equipe" area to the outside. I explain to us:

I have an area named "Equipe", i access from my layout on my main page:

_Layout.cs:

<li class="nav-item">
   <a class="nav-link" href="Home/Equipe">Equipe</a>
</li>

enter image description here

Once i click everything is good. i select another option inside this "Equipe" View so i get in this address which is working fine (controller inside my "Equipe" area) :

enter image description here

If i click on the Layout option "Equipe" i will like to see the "/Home/Equipe" page. Instead of this i have an error:

enter image description here

I guess is a problem on my routing (areas to the outside), but i don't have any idea how i should configure to redirect to the good view.

Here is my RouteConfig.cs:

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }

EquipeAreaRegistration.cs:

        public override void RegisterArea(AreaRegistrationContext context) 
        {
            context.MapRoute(
                "Equipe_default",
                "Equipe/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }

Can someone help me please? :) Thanks in advance the routing thing is still a little incomprehensible for me.

Upvotes: 0

Views: 117

Answers (1)

JyothiJ
JyothiJ

Reputation: 315

Can you try changing your reference path as below..

<li class="nav-item">
 <a class="nav-link" href="~/Home/Equipe">Equipe</a>
</li>

Upvotes: 1

Related Questions