I have a problem with Html.ActionLink
method.
If I use
@Html.ActionLink("Some text", "MyAction", "MyController", new { id = 1234 }, null)
I get a link with this href:
http://web.com/MyController/MyAction/1234
That is fine, but if I use more route values like
@Html.ActionLink("Some text", "MyAction", "MyController", new { id = 1234, param1 = 3, param2 = 10 }, null)
I get a link with this href:
http://web.com/MyController/MyAction/1234?param1=3¶m2=10
But I need:
http://web.com/MyController/MyAction/1234/3/10
Do you know how can I get it?
Edition to give more info:
In MyController code file I have that:
[Route("MyController/MyAction/{id}")]
public ActionResult MyAction(string id) { /* some code */ }
[Route("MyController/MyAction/{id}/{param1}/{param2}")]
public ActionResult MyAction(string id, byte param1, byte param2) { /* some code */ }
And this is my RouteCofig.cs file:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}