From c319201b6ea5c081b5cc0767d558f643ce0b5e5a Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Mon, 17 Jun 2019 17:24:31 -0500 Subject: [PATCH] Route data on the HttpContext scenario (#12913) --- aspnetcore/fundamentals/routing.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/routing.md b/aspnetcore/fundamentals/routing.md index 26fdf31012..aa18b026bf 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: 02/13/2019 +ms.date: 06/17/2019 uid: fundamentals/routing --- # Routing in ASP.NET Core @@ -135,6 +135,21 @@ Routing is connected to the [middleware](xref:fundamentals/middleware/index) pip URL matching is the process by which routing dispatches an incoming request to an *endpoint*. This process is based on data in the URL path but can be extended to consider any data in the request. The ability to dispatch requests to separate handlers is key to scaling the size and complexity of an app. +::: moniker-end + +::: moniker range=">= aspnetcore-3.0" + +When a Routing Middleware executes, it sets an endpoint (`Endpoint`) and route values to a feature on the . For the current request: + +* Calling `HttpContext.GetEndpoint` gets the endpoint. +* `HttpRequest.RouteValues` gets the collection of route values. + +Middleware running after the Routing Middleware can see the endpoint and take action. For example, an Authorization Middleware can interrogate the endpoint's metadata collection for an authorization policy. After all of the middleware in the request processing pipeline is executed, the selected endpoint's delegate is invoked. + +::: moniker-end + +::: moniker range=">= aspnetcore-2.2" + The routing system in endpoint routing is responsible for all dispatching decisions. Since the middleware applies policies based on the selected endpoint, it's important that any decision that can affect dispatching or the application of security policies is made inside the routing system. When the endpoint delegate is executed, the properties of [RouteContext.RouteData](xref:Microsoft.AspNetCore.Routing.RouteContext.RouteData) are set to appropriate values based on the request processing performed thus far.