I am working on my first MVC project and using attribute routing within my controllers. I am having a slight issue with one of my actions which has two possible route paths. The routes themselves are working but the actionLinks being generated are not to my liking.
Routes:
[Route("add")]
[Route("{parentId:int?}/add")]
ActionLink definition:
@Html.ActionLink("Add Category", "Add", "Category", new { parentId = @Model.CurrentCategoryId}, new { @Class = "btn btn-primary"})
This works, but when a currentCategoryId is not null the link produced is this:
/categories/add?parentId=2
but what i would like to see (which is picked up when you hand roll the url) is:
/categories/2/add
is there anyway i can achieve this with the actionLink or any other MVC magic?