ASP.NET MVC 3 RC Html.Actionlink not generating link
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.Ac开发者_开发知识库tionLink 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>
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" })
精彩评论