Let\'s say I have a class
public class ItemController:Controller
{
public ActionResult Login(int id)
{
return View(\"Hi\", id);
}
}
what about this
<%=Html.ActionLink("Get Involved",
"Show",
"Home",
new
{
id = "GetInvolved"
},
new {
@class = "menuitem",
id = "menu_getinvolved"
}
)%>
With MVC5 i have done it like this and it is 100% working code....
@Html.ActionLink(department.Name, "Index", "Employee", new {
departmentId = department.DepartmentID }, null)
You guys can get an idea from this...
I wanted to add to Joseph Kingry's answer. He provided the solution but at first I couldn't get it to work either and got a result just like Adhip Gupta. And then I realized that the route has to exist in the first place and the parameters need to match the route exactly. So I had an id and then a text parameter for my route which also needed to be included too.
Html.ActionLink(article.Title, "Login", "Item", new { id = article.ArticleID, title = article.Title }, null)
Use named parameters for readability and to avoid confusions.
@Html.ActionLink(
linkText: "Click Here",
actionName: "Action",
controllerName: "Home",
routeValues: new { Identity = 2577 },
htmlAttributes: null)