I am trying to make ActionLink
a link with multiple parameters generate a link in the form
{Controller}/{Action}/{idCompania}/{idLocal}/{fecha}
But it always generates a querystring for me :
{Controller}/{Action}?idCompania=0&idLocal=21&fecha=23-12-2015
In global.asax
it I have:
routes.MapRoute(
"UltimosInformesDetail",
"UltimosInformes/Details/{idCompania}/{idLocal}/{fecha}",
new { controller = "UltimosInformes",
action = "Details",
idCompania="",
idLocal="",
fecha="" },
null
)
My ActionLink
in view:
<td>
@Html.ActionLink("Detalle",
"Details",
"UltimosInformes",
new { idCompania = item.Compania,
idLocal = item.Local.Codigo,
fecha = item.Fecha.ToString("dd-MM-yyyy")}, null)
</td>
My controller
:
public ActionResult Details(short idCompania, short idLocal,string fecha)
{
var s = RootContext.Instance.Resolve<ProblemaService>();
return View(s.ObtenerAuditoresVisita(idCompania, idLocal, DateTime.Parse(fecha)));
}
I researched on SO in English see here and here But I couldn't figure it out
I can't get it to generate the "routed" link, it always generates a querystring
I have tried your route and the syntax is fine.
The only thing that possibly generates the error is that the route
"UltimosInformesDetail"
you created was registered after the default route.The most specific paths should always go first , then the most general ones and at the end (if you still need it) the default path.