Okay, I've got this case where I have two controllers:
HomeController
MathController
I want the routing for my HomeController to stay as default:{controller}/{action}/{id}
. But I want to access the actions in the MathController with http://myurl/Task/Math/{action}
.
So what I've done is to write my RouteConfig like this:
routes.MapRoute(
name: "Math",
url: "Task/{controller}/{action}",
defaults: new { controller = "Math", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Hem", id = UrlParameter.Optional }
);
When using the above configuration and manually entering the URLs in the browser both routing methods are working. Though when trying to add a "actionLink" it always uses the Task/{Controller}/{Action}
route. Even if I'm creating a link for the Home controller like this: @Html.ActionLink("Hem", "Hem", "Home", null, new { @class = "navbar-brand" })
How do I configure either my routing or my action links so that I'll get the preferred functionality?