Reputation: 3
After adding htmlAttributes for @HTML.ActionLink
it throws an error:
"Cannot resolve action Index"
@Html.ActionLink(" ","Index",routeValues: "Home", htmlAttributes: new { @class = "black" })
Without that attribute ActionLink
works fine:
@Html.ActionLink(" ", "Index", "Home")
Upvotes: 0
Views: 40
Reputation: 218752
First of all, you need a non empty text as the first parameter so that it will be shown as the link text. Also i think you are using the helper method incorrect.
This should work.
@Html.ActionLink("Home", "Index", "Home", null, new { @class = "black" })
If you want to pass some route values (which will be come querystring key-values), replace the null
with an anonymous object.
@Html.ActionLink("Home", "Index", "Home", new { id=123} , new { @class = "black" })
Upvotes: 1