Below is some simple code
public class Startup {
public void ConfigureServices(IServiceCollection services) {
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
app.UseDeveloperExceptionPage();
app.UseRouting();
app.Use(async (context, next) => {
var endpoint = context.GetEndpoint(); // <--------I put a debugger here
await next();
});
app.UseEndpoints(endpoints => {
endpoints.MapGet("routing", async context => {
await context.Response.WriteAsync("Request Was Routed");
});
});
app.Use(async (context, next) => {
await context.Response.WriteAsync("Terminal Middleware Reached");
});
}
}
When the breakpoint is hit, I can see some properties has been added to the Endpoint instance, for example, RoutePattern property

But Endpoint doesn't have a RoutePattern property:
public class Endpoint {
public Endpoint(RequestDelegate requestDelegate, EndpointMetadataCollection metadata, string displayName);
public string DisplayName { get; }
public EndpointMetadataCollection Metadata { get; }
public RequestDelegate RequestDelegate { get; }
public override string ToString();
Then how does RoutePattern property is added to the Endpoint instance?
Another question is, when I run the application, the breakpoint always get hit twice, not once, why is that, because there is only one request, the breakpoint should only hit once?
