diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/ControllerLinkGeneratorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/ControllerLinkGeneratorExtensions.cs
index 01481bf488..fb02fae6f4 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/ControllerLinkGeneratorExtensions.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/ControllerLinkGeneratorExtensions.cs
@@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Routing
///
public static class ControllerLinkGeneratorExtensions
{
- private static readonly LinkGenerationTemplateOptions _templateOptions = new LinkGenerationTemplateOptions()
- {
- UseAmbientValues = true,
- };
-
///
/// Generates a URI with an absolute path based on the provided values.
///
@@ -224,41 +219,6 @@ namespace Microsoft.AspNetCore.Routing
return generator.GetUriByAddress(address, address.ExplicitValues, scheme, host, pathBase, fragment, options);
}
- ///
- /// Gets a based on the provided , , and .
- ///
- /// The .
- /// The action name. Used to resolve endpoints.
- /// The controller name. Used to resolve endpoints.
- /// The route values. Optional. Used to resolve endpoints and expand parameters in the route template.
- ///
- /// A if one or more endpoints matching the address can be found, otherwise null.
- ///
- public static LinkGenerationTemplate GetTemplateByAction(
- this LinkGenerator generator,
- string action,
- string controller,
- object values = default)
- {
- if (generator == null)
- {
- throw new ArgumentNullException(nameof(generator));
- }
-
- if (action == null)
- {
- throw new ArgumentNullException(nameof(action));
- }
-
- if (controller == null)
- {
- throw new ArgumentNullException(nameof(controller));
- }
-
- var address = CreateAddress(httpContext: null, action, controller, values);
- return generator.GetTemplateByAddress(address, _templateOptions);
- }
-
private static RouteValuesAddress CreateAddress(HttpContext httpContext, string action, string controller, object values)
{
var explicitValues = new RouteValueDictionary(values);
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/PageLinkGeneratorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/PageLinkGeneratorExtensions.cs
index ec508a9645..a7e9cde9c0 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/PageLinkGeneratorExtensions.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/PageLinkGeneratorExtensions.cs
@@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Routing
///
public static class PageLinkGeneratorExtensions
{
- private static readonly LinkGenerationTemplateOptions _templateOptions = new LinkGenerationTemplateOptions()
- {
- UseAmbientValues = true,
- };
-
///
/// Generates a URI with an absolute path based on the provided values.
///
@@ -216,36 +211,6 @@ namespace Microsoft.AspNetCore.Routing
return generator.GetUriByAddress(address, address.ExplicitValues, scheme, host, pathBase, fragment, options);
}
- ///
- /// Gets a based on the provided , , and .
- ///
- /// The .
- /// The page name. Used to resolve endpoints.
- /// The page handler name. Optional.
- /// The route values. Optional. Used to resolve endpoints and expand parameters in the route template.
- ///
- /// A if one or more endpoints matching the address can be found, otherwise null.
- ///
- public static LinkGenerationTemplate GetTemplateByPage(
- this LinkGenerator generator,
- string page,
- string handler = default,
- object values = default)
- {
- if (generator == null)
- {
- throw new ArgumentNullException(nameof(generator));
- }
-
- if (page == null)
- {
- throw new ArgumentNullException(nameof(page));
- }
-
- var address = CreateAddress(httpContext: null, page, handler, values);
- return generator.GetTemplateByAddress(address, _templateOptions);
- }
-
private static RouteValuesAddress CreateAddress(HttpContext httpContext, string page, string handler, object values)
{
var explicitValues = new RouteValueDictionary(values);
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/ControllerLinkGeneratorExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/ControllerLinkGeneratorExtensionsTest.cs
index 29a197d67f..a07cad51cb 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/ControllerLinkGeneratorExtensionsTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/ControllerLinkGeneratorExtensionsTest.cs
@@ -168,27 +168,6 @@ namespace Microsoft.AspNetCore.Routing
Assert.Equal("http://example.com/Foo/Bar%3Fencodeme%3F/Home/Index/?query=some%3Fquery#Fragment?", uri);
}
- [Fact]
- public void GetTemplateByAction_CreatesTemplate()
- {
- // Arrange
- var endpoint1 = CreateEndpoint(
- "Home/Index/{id}",
- metadata: new[] { new RouteValuesAddressMetadata(routeName: null, new RouteValueDictionary(new { controller = "Home", action = "Index", })) });
- var endpoint2 = CreateEndpoint(
- "Home/Index/{id?}",
- metadata: new[] { new RouteValuesAddressMetadata(routeName: null, new RouteValueDictionary(new { controller = "Home", action = "Index", })) });
-
- var linkGenerator = CreateLinkGenerator(endpoint1, endpoint2);
-
- // Act
- var template = linkGenerator.GetTemplateByAction(action: "Index", controller: "Home");
-
- // Assert
- Assert.NotNull(template);
- Assert.Equal("/Home/Index/17", template.GetPath(new { id = 17 }));
- }
-
private RouteEndpoint CreateEndpoint(
string template,
object defaults = null,
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/PageLinkGeneratorExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/PageLinkGeneratorExtensionsTest.cs
index 89531042f1..3fc85649c6 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/PageLinkGeneratorExtensionsTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/PageLinkGeneratorExtensionsTest.cs
@@ -166,29 +166,6 @@ namespace Microsoft.AspNetCore.Routing
Assert.Equal("http://example.com/Foo/Bar%3Fencodeme%3F/Admin/ManageUsers/?query=some%3Fquery#Fragment?", uri);
}
- [Fact]
- public void GetTemplateByAction_CreatesTemplate()
- {
- // Arrange
- var endpoint1 = CreateEndpoint(
- "About/{id}",
- defaults: new { page = "/About", },
- metadata: new[] { new RouteValuesAddressMetadata(routeName: null, new RouteValueDictionary(new { page = "/About", })) });
- var endpoint2 = CreateEndpoint(
- "Admin/ManageUsers",
- defaults: new { page = "/Admin/ManageUsers", },
- metadata: new[] { new RouteValuesAddressMetadata(routeName: null, new RouteValueDictionary(new { page = "/Admin/ManageUsers", })) });
-
- var linkGenerator = CreateLinkGenerator(endpoint1, endpoint2);
-
- // Act
- var template = linkGenerator.GetTemplateByPage(page: "/About");
-
- // Assert
- Assert.NotNull(template);
- Assert.Equal("/About/17", template.GetPath(new { id = 17 }));
- }
-
private RouteEndpoint CreateEndpoint(
string template,
object defaults = null,