Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.ActionLink (): new { route value} is acting strangely. I don't know where length = 17 parameter is coming from

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

like image 613
Richard77 Avatar asked Dec 12 '22 20:12

Richard77


1 Answers

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.

like image 51
Castrohenge Avatar answered Dec 28 '22 10:12

Castrohenge