Reputation: 21621
I've this link on a page
<% = Html.ActionLink(item.Title, "Edit", "ArticleManagement",
new { id = item.ArticleDataID })%>
and a simple method to receive the article Id
public ActionResult Edit(int id)
{
//Do something
}
Unfortunately, I'm getting an error" parameter dictionary contains a null value for parameter id of int32 for Edit(Int32)..."
When I check the Url, I see something like "http://localhost:59786/ArticleManagement/Edit?Length=17"
What is "Length=17"? and what's doing there? Anyway, so far I'm working with a collection that has only 3 items on it.
Thanks for helping
Upvotes: 4
Views: 10387
Reputation: 8983
You need to add null as the last parameter:
<%=Html.ActionLink("Title", "Edit", "ArticleManagement",
new { id = 1 }, new { @class = "link-class", attr = "attribute value" })%>
I think it uses you route values as html attributes without the null.
Upvotes: 13
Reputation: 1255
I've had this happen as well, it seems to happen when the actionlink can't match to a route.
Length 17 corresponds to the length of articlemanagement.
Edit: It might have something to do with the overload of ActionLink.
Upvotes: 0