Questo è un esempio di "sovraccarico inferno" in ASP.NET MVC.
Il primo codice chiama il seguente metodo:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
Object routeValues,
Object htmlAttributes
)
mentre il secondo codice chiama questo:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
Object routeValues,
Object htmlAttributes
)
Si noti che il parametro di stringa controllerName
nella prima chiamata sta diventando routeValues
nella seconda uno. Il valore stringa "Prodotto" viene passato ai valori instradati: viene utilizzata la proprietà stringa Length
, che ha una lunghezza di 7 qui, quindi "Lunghezza = 7" che stai ricevendo nel percorso.
Considerando il primo metodo, sembra che abbiate invertito i parametri routeValues
e htmlAttributes
.
fonte
2010-05-24 14:08:12