ckv
ckv

Reputation: 10830

When to use Html.RouteLink() and difference against Html.ActionLink()

I am learning ASP.NET MVC and came across this particular Html Helper method.

When would one use

@Html.RouteLink("Routed Link", new { controller = "Home", action = "About", id="MyID"})

What is the difference between this and Html.ActionLink()?

Upvotes: 1

Views: 746

Answers (2)

Brian Mains
Brian Mains

Reputation: 50728

ActionLink is a specific way to link to a specific action by specifying the action and controller. RouteLink gives you more control over the routing. For instance, look at this override which gives you the most flexibility in generating a URL, not necessarily tied to an action.

Upvotes: 1

whoah
whoah

Reputation: 4443

According to: What's the difference between RouteLink and ActionLink in ASP.NET MVC?

ActionLink will generate the URL to get to an action using the first matching route by action name.

RouteLink will generate a URL to a specific route determined either by name or route values.

Upvotes: 1

Related Questions