By mistake I took the wrong constructor in an ActionLink
:
@Html.ActionLink("Show Customer", "Load", "Customer", new {Model.Id });
The error is, that the last parameter is of type htmlAttributes
and not of routeValues
(as expected). So the right constructor would have been:
@Html.ActionLink("Show Customer", "Load", "Customer", new {Model.Id }, null);
So I do not need to solve that problem... I just wonder, when I used the wrong constructor, my routeValue must have been interpreted as an htmlAttribute
.
I was just surprised that it results in a length
-Parameter. The generated code was:
/Customer/Load?Length=7
Just by curiosity: Where does the length=7
come from?
This is overload of ActionLink, which is getting hit:
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes);
So your only route value is string, controller name, "Customer", which has public property Length, 8 symbols. And routeValues is picking with reflections all public properties of object, which was passed to it.
And worth to mention, that your link will receive html attribute Id='whatever_id_model_holds', since 4th parameter is mapped to htmlAttributes.
TAKEN FROM https://stackoverflow.com/a/4360565/7720
The ActionLink override you are using matches to the (string linkText, string actionName, Object routeValues, Object htmlAttributes) override. So your "Customer" value is being passed to the routeValues parameter. The behavior of this function with respect to this parameter is to take all public properties on it and add it to the list of route values used to generate the link. Since a String only has one public property (Length) you end up with "length=7".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With