0
votes

I have the following routes and typing them in the browser works fine and routes correctly, but if I use a Html.ActionLink, it tries using the DefaultStuff Route.

Routes

_routes.MapStuffRoute(
    "DefaultStuff",
    "stuff/{controller}/{id}",
    new { id = UrlParameter.Optional },
    new[] { typeof(BaseApiController).Namespace });

_routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    new[] { typeof(BaseController).Namespace });

Page

@Html.ActionLink("Job Queues", "Index", "Job") // generates http://localhost/stuff/job?action=Index

What am I missing to allow ActionLink to generate http://localhost/stuff/index. Reversing the routes the ActionLink is correct but the Stuff does not work. Just a note, the StuffRoute sets the action name based on the information in the request.

1

1 Answers

1
votes

It seems as though you actually are trying to map the controller "Job" to stuff. Currently your "DefaultStuff" route does not resolve an action, so it is putting it in as a query string value.

_routes.MapRoute(
"DefaultStuff",
"stuff/{action}/{id}",
new { controller="Job", id = UrlParameter.Optional },
new[] { typeof(BaseApiController).Namespace });