Fix for #246 - ActionLink generating wrong urls

There's an overload that's missing from ActionLink but is present on url
helper, making it very easy to mistakenly pass the wrong data. In the case
of #246, the controller name is treated as the route-values and the
route-values treated as html attributes, leading to the wrong link being
generated.
This commit is contained in:
Ryan Nowak 2014-04-15 12:52:39 -07:00
parent 5810215306
commit f34ed467e4
1 changed files with 18 additions and 0 deletions

View File

@ -71,6 +71,24 @@ namespace Microsoft.AspNet.Mvc.Rendering
htmlAttributes: null);
}
public static HtmlString ActionLink<TModel>(
[NotNull] this IHtmlHelper<TModel> helper,
[NotNull] string linkText,
string actionName,
string controllerName,
object routeValues)
{
return helper.ActionLink(
linkText,
actionName,
controllerName,
protocol: null,
hostname: null,
fragment: null,
routeValues: routeValues,
htmlAttributes: null);
}
public static HtmlString ActionLink<TModel>(
[NotNull] this IHtmlHelper<TModel> helper,
[NotNull] string linkText,