Patch example in Routing topic (#10135)
parent
566cd32833
commit
5df41d5033
|
@ -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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue