Using Html.ActionLink to call action on different controller
I would recommend writing these helpers using named parameters for the sake of clarity as follows:
@Html.ActionLink(
linkText: "Details",
actionName: "Details",
controllerName: "Product",
routeValues: new {
id = item.ID
},
htmlAttributes: null
)
What you want is this overload :
//linkText, actionName, controllerName, routeValues, htmlAttributes
<%=Html.ActionLink("Details", "Details",
"Product", new {id = item.ID}, null) %>
If you grab the MVC Futures assembly (which I would highly recommend) you can then use a generic when creating the ActionLink and a lambda to construct the route:
<%=Html.ActionLink<Product>(c => c.Action( o.Value ), "Details" ) %>
You can get the futures assembly here: http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471
With that parameters you're triggering the wrong overloaded function/method.
What worked for me:
<%= Html.ActionLink("Details", "Details", "Product", new { id=item.ID }, null) %>
It fires HtmlHelper.ActionLink(string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
I'm using MVC 4.
Cheerio!