diff --git a/samples/MvcSample/LinkController.cs b/samples/MvcSample/LinkController.cs index 159985f2ae..1f5c2f85a0 100644 --- a/samples/MvcSample/LinkController.cs +++ b/samples/MvcSample/LinkController.cs @@ -19,5 +19,15 @@ namespace MvcSample { return Url.Route(new { controller = "Home", action = "Details" }); } + + public string Link1() + { + return Url.Action("Index", "Home"); + } + + public string Link2() + { + return Url.Action("Link2"); + } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionResults/ViewResult.cs b/src/Microsoft.AspNet.Mvc.Core/ActionResults/ViewResult.cs index 8ca0c780a1..748f5c5180 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionResults/ViewResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionResults/ViewResult.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc { var viewContext = new ViewContext(context.HttpContext, ViewData, _serviceProvider) { - Url = new DefaultUrlHelper(context.HttpContext, context.Router, context.RouteValues), + Url = new UrlHelper(context.HttpContext, context.Router, context.RouteValues), }; await view.RenderAsync(viewContext, writer); } @@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc ViewEngineResult result = await _viewEngine.FindView(actionContext, viewName); if (!result.Success) { - string locationsText = String.Join(Environment.NewLine, result.SearchedLocations); + string locationsText = string.Join(Environment.NewLine, result.SearchedLocations); const string message = @"The view '{0}' was not found. The following locations were searched:{1}."; throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, message, viewName, locationsText)); } diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs index de9d8bdff0..0692adf56f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs @@ -61,12 +61,12 @@ namespace Microsoft.AspNet.Mvc } else if (prop.Name == "Url" && prop.PropertyType == typeof(IUrlHelper)) { - var generator = new DefaultUrlHelper( + var urlHelper = new UrlHelper( actionContext.HttpContext, actionContext.Router, actionContext.RouteValues); - prop.SetValue(controller, generator); + prop.SetValue(controller, urlHelper); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultUrlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs similarity index 89% rename from src/Microsoft.AspNet.Mvc.Core/DefaultUrlHelper.cs rename to src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs index 0a25f12a36..94374a71f3 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultUrlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs @@ -4,13 +4,13 @@ using Microsoft.AspNet.Routing; namespace Microsoft.AspNet.Mvc { - public class DefaultUrlHelper : IUrlHelper + public class UrlHelper : IUrlHelper { private readonly HttpContext _httpContext; private readonly IRouter _router; private readonly IDictionary _ambientValues; - - public DefaultUrlHelper(HttpContext httpContext, IRouter router, IDictionary ambientValues) + + public UrlHelper([NotNull] HttpContext httpContext, [NotNull] IRouter router, [NotNull] IDictionary ambientValues) { _httpContext = httpContext; _router = router; diff --git a/src/Microsoft.AspNet.Mvc.Rendering/UrlHelperExtensions.cs b/src/Microsoft.AspNet.Mvc.Rendering/UrlHelperExtensions.cs index 8d65290975..9eeedd3000 100644 --- a/src/Microsoft.AspNet.Mvc.Rendering/UrlHelperExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Rendering/UrlHelperExtensions.cs @@ -5,22 +5,22 @@ namespace Microsoft.AspNet.Mvc { public static string Action([NotNull] this IUrlHelper generator) { - return generator.Action(null, null, null); + return generator.Action(action: null, controller: null, values: null); } public static string Action([NotNull] this IUrlHelper generator, string action) { - return generator.Action(action, null, null); + return generator.Action(action: action, controller: null, values: null); } public static string Action([NotNull] this IUrlHelper generator, string action, object values) { - return generator.Action(action, null, values); + return generator.Action(action: action, controller: null, values: values); } public static string Action([NotNull] this IUrlHelper generator, string action, string controller) { - return generator.Action(action, controller, null); + return generator.Action(action: action, controller: controller, values: null); } } }