I have one area Area1
with controller Home
and it's Index
method.
I also have created another area Area2
with controller Home
and it's Index
method.
In Area1
I have action link that should open Index
page in Area2
.
@Html.ActionLink("Link to another area index", "Index", "Home", new { area = "Area2" }, null)
But when I click on this link it first go to Area1/Home/Index
!
Why is this happening. Is this has to be like this or it can go directly to Area2/Home/Index
?
This makes me problem because in Area1/Home/Index I need some parameters and when this happens this valuer are null or wrong and make me problem. I must doing something wrong.
Update
Area1 routing
public override void RegisterArea(AreaRegistrationContext context)
{
context.Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
context.MapRoute(
"Area1_home",
"{country}/{city}",
new { controller = "Home", action = "Index", country = UrlParameter.Optional, city = UrlParameter.Optional }
);
context.MapRoute(
"Area1_default",
"Area1/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Area2 routing:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Area2_default",
"Area2/{controller}/{action}/{id}",
new { controller="Home", action = "Index", id = UrlParameter.Optional }
);
}