diff --git a/aspnetcore/fundamentals/routing.md b/aspnetcore/fundamentals/routing.md
index 8c9ddad213..3c0a7347ac 100644
--- a/aspnetcore/fundamentals/routing.md
+++ b/aspnetcore/fundamentals/routing.md
@@ -5,7 +5,7 @@ description: Discover how ASP.NET Core routing is responsible for matching HTTP
monikerRange: '>= aspnetcore-2.1'
ms.author: riande
ms.custom: mvc
-ms.date: 3/25/2020
+ms.date: 4/1/2020
uid: fundamentals/routing
---
# Routing in ASP.NET Core
@@ -574,7 +574,7 @@ The preceding constraint is applied in the following code:
[!code-csharp[](routing/samples/3.x/RoutingSample/Controllers/TestController.cs?name=snippet&highlight=6,13)]
-The [MyDisplayRouteInfo](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Extensions/ControllerContextExtensions.cs) method is included in the [sample download](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/routing/samples/3.x) and is used to display routing information.
+[!INCLUDE[](~/includes/MyDisplayRouteInfo.md)]
The implementation of `MyCustomConstraint` prevents `0` being applied to a route parameter:
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/GadgetController.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/GadgetController.cs
index 62b04ba95d..b1f13d4fe4 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/GadgetController.cs
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/GadgetController.cs
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/HomeController.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/HomeController.cs
index 1228857cc4..26e3e87af0 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/HomeController.cs
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/HomeController.cs
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/ProductController.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/ProductController.cs
index b52686e857..b12665ea13 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/ProductController.cs
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/ProductController.cs
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/TestController.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/TestController.cs
index 21b2f65dfd..7811db76e0 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/TestController.cs
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/TestController.cs
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/WidgetController.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/WidgetController.cs
index 7f7ddd0d4a..32a154a4e8 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/WidgetController.cs
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Controllers/WidgetController.cs
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Extensions/ControllerContextExtensions.cs b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Extensions/ControllerContextExtensions.cs
deleted file mode 100644
index 6fd50a1a5c..0000000000
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/Extensions/ControllerContextExtensions.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-
-#region snippet
-internal static class ControllerContextExtensions
-{
- public static IActionResult MyDisplayRouteInfo(this ControllerContext ctx, int? id, string msg = null) =>
- ctx.MyDisplayRouteInfo(id?.ToString(), msg);
-
- public static IActionResult MyDisplayRouteInfo(this ControllerContext ctx,
- string id = null, string msg = null)
- {
- var actionDescriptor = ctx.ActionDescriptor;
- var routeTemplate = actionDescriptor?.AttributeRouteInfo?.Template;
- var routeName = actionDescriptor.AttributeRouteInfo?.Name;
- var actionName = actionDescriptor.ActionName;
- var controllerName = actionDescriptor.ControllerName;
- var routeOrder = actionDescriptor.AttributeRouteInfo?.Order;
- var method = ctx.HttpContext.Request.Method;
-
- var tms = (routeTemplate == null) ? "" : $"Template = {routeTemplate}";
- var ids = (string.IsNullOrEmpty(id)) ? "" : $"id = {id}";
- var ors = (routeOrder == null) ? "" : $"Order = {routeOrder}";
- var methods = (method == "GET") ? "" : $"{method}";
-
- return new ContentResult
- {
- Content = $"{methods} {ids} {ors} {tms} {controllerName}.{actionName} {routeName} {msg}"
- };
- }
-}
-#endregion
\ No newline at end of file
diff --git a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/RoutingSample.csproj b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/RoutingSample.csproj
index dd2dd92ba7..644181b47c 100644
--- a/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/RoutingSample.csproj
+++ b/aspnetcore/fundamentals/routing/samples/3.x/RoutingSample/RoutingSample.csproj
@@ -7,6 +7,7 @@
+
-
+
diff --git a/aspnetcore/includes/MyDisplayRouteInfo.md b/aspnetcore/includes/MyDisplayRouteInfo.md
new file mode 100644
index 0000000000..a7b6914545
--- /dev/null
+++ b/aspnetcore/includes/MyDisplayRouteInfo.md
@@ -0,0 +1 @@
+[MyDisplayRouteInfo](https://github.com/Rick-Anderson/RouteInfo/blob/master/Microsoft.Docs.Samples.RouteInfo/ControllerContextExtensions.cs) is provided by the [Rick.Docs.Samples.RouteInfo](https://www.nuget.org/packages/Rick.Docs.Samples.RouteInfo) NuGet package and displays route information.
diff --git a/aspnetcore/mvc/controllers/routing.md b/aspnetcore/mvc/controllers/routing.md
index b02f4250cf..da735e93b1 100644
--- a/aspnetcore/mvc/controllers/routing.md
+++ b/aspnetcore/mvc/controllers/routing.md
@@ -45,18 +45,17 @@ The route template `"{controller=Home}/{action=Index}/{id?}"`:
* Matches a URL path like `/Products/Details/5`
* Extracts the route values `{ controller = Products, action = Details, id = 5 }` by tokenizing the path. The extraction of route values results in a match if the app has a controller named `ProductsController` and a `Details` action:
-[!code-csharp[](routing/samples/3.x/main/Controllers/ProductsController.cs?name=snippetA)]
+ [!code-csharp[](routing/samples/3.x/main/Controllers/ProductsController.cs?name=snippetA)]
- The [MyDisplayRouteInfo](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/mvc/controllers/routing/samples/3.x/main/Extensions/ControllerContextExtensions.cs) method is included in the [sample download](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/mvc/controllers/routing/samples/3.x) and is used to display routing information.
+ [!INCLUDE[](~/includes/MyDisplayRouteInfo.md)]
- * `/Products/Details/5` model binds the value of `id = 5` to set the `id` parameter to `5`. See [Model Binding](xref:mvc/models/model-binding) for more details.
+* `/Products/Details/5` model binds the value of `id = 5` to set the `id` parameter to `5`. See [Model Binding](xref:mvc/models/model-binding) for more details.
* `{controller=Home}` defines `Home` as the default `controller`.
* `{action=Index}` defines `Index` as the default `action`.
* The `?` character in `{id?}` defines `id` as optional.
* Default and optional route parameters don't need to be present in the URL path for a match. See [Route Template Reference](xref:fundamentals/routing#route-template-reference) for a detailed description of route template syntax.
* Matches the URL path `/`.
* Produces the route values `{ controller = Home, action = Index }`.
-* The [MyDisplayRouteInfo](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/mvc/controllers/routing/samples/3.x/main/Extensions/ControllerContextExtensions.cs) method is included in the [sample download](https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/mvc/controllers/routing/samples/3.x) and is used to display routing information.
The values for `controller` and `action` make use of the default values. `id` doesn't produce a value since there's no corresponding segment in the URL path. `/` only matches if there exists a `HomeController` and `Index` action:
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/BlogController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/BlogController.cs
index c7c7bab075..2a7bccbd82 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/BlogController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/BlogController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/HomeController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/HomeController.cs
index a4a1763d4a..98929d5802 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/HomeController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/HomeController.cs
@@ -9,6 +9,7 @@
#define Five
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo2Controller.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo2Controller.cs
index 8b1264c83e..30a8ae5f14 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo2Controller.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo2Controller.cs
@@ -1,6 +1,6 @@
#define First
using Microsoft.AspNetCore.Mvc;
-
+using Microsoft.Docs.Samples;
namespace RoutingSample.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo3Controller.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo3Controller.cs
index fb75165740..aca6f1a5d1 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo3Controller.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemo3Controller.cs
@@ -1,7 +1,8 @@
-//#define MYDEMO4
+//define MYDEMO4
//#define MYDEMO3
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
// This uses same routes as HomeController, so only one can be defined without setting order
// Test with webBuilder.UseStartup();
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemoController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemoController.cs
index ff9d41fc48..ed76d953d0 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemoController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyDemoController.cs
@@ -1,6 +1,7 @@
#define MYDEMO
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
// This uses same routes as HomeController, and MyDemo3Controller so only one can be defined
// Test with webBuilder.UseStartup();
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyProductsController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyProductsController.cs
index 12aab99fde..e8a0bdd616 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyProductsController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyProductsController.cs
@@ -1,5 +1,6 @@
#define PROD1
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyTestApiController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyTestApiController.cs
index f3ac17588a..45d6914588 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyTestApiController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/MyTestApiController.cs
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using System;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsApiController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsApiController.cs
index 7f0914234c..0c0cfae05a 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsApiController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsApiController.cs
@@ -2,6 +2,7 @@
#define PROD2
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsController.cs
index 98c31449df..8e9091aabc 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/ProductsController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/SubscriptionManagementController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/SubscriptionManagementController.cs
index 0c674746ba..ed2c6a978f 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/SubscriptionManagementController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/SubscriptionManagementController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/Test2Controller.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/Test2Controller.cs
index 2180805648..edf5094b2f 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/Test2Controller.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/Test2Controller.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
namespace WebMvcRouting.Controllers
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGeneration2Controller.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGeneration2Controller.cs
index 7a714b5408..97d0cf1882 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGeneration2Controller.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGeneration2Controller.cs
@@ -3,10 +3,12 @@
// This is the ultimate greedy route
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
+
namespace WebMvcRouting.Controllers
{
- #region snippet_1
- #region snippet_2
+#region snippet_1
+#region snippet_2
public class UrlGeneration2Controller : Controller
{
[HttpGet("")]
@@ -15,14 +17,14 @@ namespace WebMvcRouting.Controllers
var url = Url.RouteUrl("Destination_Route");
return ControllerContext.MyDisplayRouteInfo("", $" URL = {url}");
}
- #endregion
+#endregion
[HttpGet("custom/url/to/destination2", Name = "Destination_Route")]
public IActionResult Destination()
{
return ControllerContext.MyDisplayRouteInfo();
}
- #endregion
+#endregion
}
}
#endif
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationAttrController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationAttrController.cs
index ef94fba04e..e010ce2e1d 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationAttrController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationAttrController.cs
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
+
#region snippet_1
public class UrlGenerationAttrController : Controller
{
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationController.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationController.cs
index d0a875682b..32f09ec5bc 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationController.cs
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Controllers/UrlGenerationController.cs
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Docs.Samples;
+
namespace WebMvcRouting.Controllers
{
#region snippet_1
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Extensions/ControllerContextExtensions.cs b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Extensions/ControllerContextExtensions.cs
deleted file mode 100644
index 1ab8e182bb..0000000000
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Extensions/ControllerContextExtensions.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-
-#region snippet
-internal static class ControllerContextExtensions
-{
- public static IActionResult MyDisplayRouteInfo(this ControllerContext ctx, int ?id, string msg = null) =>
- ctx.MyDisplayRouteInfo(id?.ToString(), msg);
-
- public static IActionResult MyDisplayRouteInfo(this ControllerContext ctx,
- string id = null, string msg = null)
- {
- var actionDescriptor = ctx.ActionDescriptor;
- var routeTemplate = actionDescriptor?.AttributeRouteInfo?.Template;
- var routeName = actionDescriptor.AttributeRouteInfo?.Name;
- var actionName = actionDescriptor.ActionName;
- var controllerName = actionDescriptor.ControllerName;
- var routeOrder = actionDescriptor.AttributeRouteInfo?.Order;
- var method = ctx.HttpContext.Request.Method;
-
- var tms = (routeTemplate == null) ? "" : $"Template = {routeTemplate}";
- var ids = (string.IsNullOrEmpty(id)) ? "" : $"id = {id}";
- var ors = (routeOrder == null) ? "" : $"Order = {routeOrder}";
- var methods = (method == "GET") ? "" : $"{method}";
-
- return new ContentResult {
- Content = $"{methods} {ids} {ors} {tms} {controllerName}.{actionName} {routeName} {msg}" };
- }
-}
-#endregion
\ No newline at end of file
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Views/Shared/TestLinks.cshtml b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Views/Shared/TestLinks.cshtml
index 5d07341fed..1c19bbeda2 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/Views/Shared/TestLinks.cshtml
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/Views/Shared/TestLinks.cshtml
@@ -36,7 +36,7 @@
- ZZ
+
diff --git a/aspnetcore/mvc/controllers/routing/samples/3.x/main/WebMvcRouting.csproj b/aspnetcore/mvc/controllers/routing/samples/3.x/main/WebMvcRouting.csproj
index dd2dd92ba7..db255e46bb 100644
--- a/aspnetcore/mvc/controllers/routing/samples/3.x/main/WebMvcRouting.csproj
+++ b/aspnetcore/mvc/controllers/routing/samples/3.x/main/WebMvcRouting.csproj
@@ -7,6 +7,7 @@
+