I have a MVC4 Index page that have the following links:
@Html.ActionLink("FOO", "Index", "Mil", new { year = String.Empty, id = String.Empty }, null)
@Html.ActionLink("BAR", "Index", "Euro", new { year = String.Empty, id = String.Empty }, null)
But oddly both turn into a hyperlink to the CURRENT path (i.e. if we are at domain/Euro/2016/1 both link to this address), instead of pointing to the specified controller.
Everything normal in RouteConfig:
routes.MapRoute(
name: "Default",
url: "{controller}/{year}/{id}",
defaults: new { controller = "Home", action = "Index", year = UrlParameter.Optional, id = UrlParameter.Optional }
);
The Controllers/Actions exist and work fine:
EuroController:
public ActionResult Index(int? year, int? id)
{
...
}
What can be causing this odd behavior?
EDIT:
If i pass year parameter, works fine: @Html.ActionLink("FOO", "Index", "Mil", new { year = 666, id = String.Empty }, null)
correctly points to domain/Mil/666.