An endpoint is the handler selected to process an HTTP request. ASP.NET Core routing matches the request URL against routes, selects an endpoint, and executes it to produce a response. An MVC controller action can be an endpoint; a mapped C# handler can be one too. section 2.3.4 section 13.1.1
Routes keep URL matching out of response-producing code. Without routing, individual middleware components may each inspect paths, leaving URL dependencies scattered across the application. A route instead expresses the mapping between a URL and the endpoint responsible for its response. section 13.1.1
One action, three URLs
A Home controller’s Index action can return "Hello World" for /, /Home, and /Home/Index under the project’s default route. Change the browser URL between those paths to check that each reaches the same action. section 2.3.1 section 2.3.2
Endpoint selection and execution happen at different points in the request pipeline: UseRouting selects the endpoint, and UseEndpoints executes it. Middleware placed between them can inspect the selection with HttpContext.GetEndpoint() before a response is generated. The returned Endpoint object exposes a display name, metadata, and the RequestDelegate used to generate the response. SetEndpoint can replace the selection, but interfering with routing calls for a compelling reason. section 13.3.3
Table 13.10 The properties defined by the Endpoint class (view table figure)
| Name |
Description |
|---|---|
| DisplayName |
This property returns the display name associated with the endpoint, which can be set using the WithDisplayName method when creating a route. |
| Metadata |
This property returns the collection of metadata associated with the endpoint. |
| RequestDelegate |
This property returns the delegate that will be used to generate the response. |
Use the Endpoint property table when inspecting a selected handler: DisplayName identifies it, Metadata describes it, and RequestDelegate supplies its response-producing logic. section 13.3.3
An endpoint can use application services as well as route values. For example, a sum endpoint reads a count from the route, queries an Entity Framework Core context for a stored result, and calculates and saves one if none exists. Even when a result is stored, each request in this example makes a database query; storage is not response caching. section 17.5.6
The selected endpoint can also be subject to access checks. A restricted /users/list endpoint prompts an unauthenticated visitor to log in, denies an authenticated user without the required role, and displays the Razor Page to an authorized user. section 39.3.5

























