I have three overloaded actions with similar routes; Routing is working fine, the problem is with link generation.
The code is similar to this:
[RoutePrefix("Prefix")]
public partial class MyController : Controller
{
[ActionName("Index"), Route]
public virtual ActionResult ActionMethod() {}
[ActionName("Index"), Route("{param1}")]
public virtual ActionResult ActionMethod(AnEnum param1, long? param2 = null) {}
[HttpPost, ActionName("Index"), Route("{param1}")]
public virtual ActionResult ActionMethod(Model model) {}
}
With current routes prefix/
, and prefix/EnumVal1
works just fine, the problem is with generated URLs; I get prefix/?param1=Val
for second action method, which doesn't route properly, neither does the post
action.
If I change their route's order
, first link doesn't generate properly.
[ActionName("Index"), Route("", Order = 1)]
public virtual ActionResult ActionMethod() { }
[ActionName("Index"), Route("{param1}", Order = 0)]
public virtual ActionResult ActionMethod(AnEnum param1, long? param2 = null) {}
Any idea what am I missing here? Please note that determining route names explicitly is not possible, since there are external links.