0

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>

1 Answer 1

3

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" })
Sign up to request clarification or add additional context in comments.

1 Comment

Am working against the same controller, so shouldn't need it (I tried with both). Using RouteLink worked as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.