Html.ActionLink (): The new {route value} value acts weirdly. I do not know where the parameter length = 17 comes from

I have this link on the page

<% = Html.ActionLink(item.Title, "Edit", "ArticleManagement", new { id = item.ArticleDataID })%> 

and easy way to get article id

 public ActionResult Edit(int id) { //Do something } 

Sorry, I am getting an error. The parameter dictionary contains a null value for the int32 parameter identifier for Edit (Int32) ... "

When I check Url, I see something like http: // localhost: 59786 / ArticleManagement / Edit? Length = 17 "

What is Length = 17 "? And what to do there? Anyway, while I work with a collection on which there are only 3 elements.

thanks for the help

+4
source share
2 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 your route values ​​as non-null html attributes.

+13
source

I did it too, it seems to happen when the actionlink cannot match the route.

Length 17 corresponds to the length of the control product.

Edit: this may have something to do with ActionLink overloading.

0
source

Source: https://habr.com/ru/post/1316146/


All Articles