I have on the controller:
[RoutePrefix("")]
The action with route:
[Route("things-to-do/{filter1?}/{filter2?}/{filter3?}/{filter4?}/{Area?}", Name = "thingstodo")] public async virtual Task<ActionResult> ThingsToDo(string filter1 = "", string filter2 = "", string filter3 = "", string filter4 = "", string q = "")
This works if I enter these url's in browser:
localhost/things-to-do
localhost/things-to-do/something
localhost/things-to-do/something/something
But these all return null:
Url.RouteUrl("thingstodo")
Url.Action("ThingsToDo", "ControllerName")
Url.Action(MVC.ControllerName.ThingsToDo())
These return correct url's:
Url.Action("ThingsToDo", "ControllerName", new { filter1 = "something", filter2 = "something" })
Url.Action(MVC.ControllerName.ThingsToDo("something", "something"))
Any help on how to correctly generate url's when I don't need the optional params would be appreciated.