-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
In UseEndpoints, I have a custom MapBlog and mvc route mappings
The MapBlog maps blog/{**slug} to a new IApplicationBuilder which uses a proxy middleware.
Some of the route mappings contain multiple constraints, and this somehow removes blog/{**slug} from consideration.
Example of this: {a:regex(^defaultValue$}/{b:regex(^defaultValue$}
In reality the endpoints in my project are more complex than this, but this is enough to reproduce
To Reproduce
https://github.com/serenata-keith-mifsud/AspNetCore3.1RoutingIssue
static async Task EmptyResponse(HttpContext context)
{
await context.Response.WriteAsync($"Hello World from {context.GetEndpoint().DisplayName}!");
}
app.UseEndpoints(endpoints =>
{
endpoints.Map("blog/{**blog}", endpoints.CreateApplicationBuilder().Use(next => EmptyResponse).Build()).WithDisplayName("Blog");
endpoints.MapControllerRoute("HomePage", "/", new { controller = "Home", action = "Index" }).WithDisplayName("HomePage");
endpoints.MapControllerRoute("TwoConstraints", "{a:regex(^a$)}/{b:regex(^b$)}", new { controller = "Home", action = "Index" }).WithDisplayName("TwoConstaints");
});
Microsoft.AspNetCore.Routing.Matching.DfaMatcher: Debug: 1 candidate(s) found for the request path '/blog/post'
Microsoft.AspNetCore.Routing.Matching.DfaMatcher: Debug: Endpoint 'TwoConstaints' with route pattern '{a:regex(^a$)}/{b:regex(^b$)}' was rejected by constraint 'a':'Microsoft.AspNetCore.Routing.Constraints.RegexInlineRouteConstraint' with value 'blog' for the request path '/blog/post'
Microsoft.AspNetCore.Routing.Matching.DfaMatcher: Debug: Endpoint 'TwoConstaints' with route pattern '{a:regex(^a$)}/{b:regex(^b$)}' is not valid for the request path '/blog/post'
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware: Debug: Request did not match any endpoints
Further technical details
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.100\Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db.NET Core SDKs installed:
2.0.2 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.509 [C:\Program Files\dotnet\sdk]
2.1.802 [C:\Program Files\dotnet\sdk]
2.2.402 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk].NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
IDE: Microsoft Visual Studio Professional 2019 Version 16.4.0