From 5df41d5033696cee2ba3f166f194f54155da9fb7 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sat, 29 Dec 2018 17:42:59 -0600 Subject: [PATCH] Patch example in Routing topic (#10135) --- aspnetcore/fundamentals/routing.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/routing.md b/aspnetcore/fundamentals/routing.md index 6dd58b03c0..a6a0e9760d 100644 --- a/aspnetcore/fundamentals/routing.md +++ b/aspnetcore/fundamentals/routing.md @@ -4,7 +4,7 @@ author: rick-anderson description: Discover how ASP.NET Core routing is responsible for mapping request URIs to endpoint selectors and dispatching incoming requests to endpoints. ms.author: riande ms.custom: mvc -ms.date: 11/15/2018 +ms.date: 12/29/2018 uid: fundamentals/routing --- # Routing in ASP.NET Core @@ -286,6 +286,8 @@ A few differences exist between endpoint routing in ASP.NET Core 2.2 or later an In the following example, a middleware uses the `LinkGenerator` API to create link to an action method that lists store products. Using the link generator by injecting it into a class and calling `GenerateLink` is available to any class in an app. ```csharp +using Microsoft.AspNetCore.Routing; + public class ProductsLinkMiddleware { private readonly LinkGenerator _linkGenerator; @@ -297,8 +299,7 @@ public class ProductsLinkMiddleware public async Task InvokeAsync(HttpContext httpContext) { - var url = _linkGenerator.GenerateLink(new { controller = "Store", - action = "ListProducts" }); + var url = _linkGenerator.GetPathByAction("ListProducts", "Store"); httpContext.Response.ContentType = "text/plain";