From f34ed467e48baf2cb8befe78ce52a2c1fdf72a9c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 15 Apr 2014 12:52:39 -0700 Subject: [PATCH] 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. --- .../Rendering/HtmlHelperLinkExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs index 301dab4c91..ffcb276858 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs @@ -71,6 +71,24 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: null); } + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper 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( [NotNull] this IHtmlHelper helper, [NotNull] string linkText,