Reputation: 7713
As the title says...
I have a route (the first one listed) which looks like this:
routes.MapRoute(
"TopicRoute", // Route name
"forums/{forumSlug}/{topicSlug}", // URL with parameters
new { controller = "Forums", action = "Topic"} // Parameter defaults
);
I can browse to:
/forums/my-forum/my-topic
and the page loads fine. Yet I have a Html.ActionLink that looks like:
@Html.ActionLink(item.Title, "Topic", new { forumSlug ="my-forum", topicSlug = "my-topic" })
And it won't generate the correct link syntax for me? It generates:
<a href="">My Topic</a>
Upvotes: 0
Views: 3308
Reputation: 1039418
Don't forget the controller:
@Html.ActionLink(item.Title, "Topic",
new { forumSlug ="my-forum", topicSlug = "my-topic", controller = "Forums" })
or use a named route link:
@Html.RouteLink(item.Title, "TopicRoute",
new { forumSlug = "my-forum", topicSlug = "my-topic" })
Upvotes: 3