Asp.Net Core middleware pathstring startswithsegments issue
问题 Have a Asp.NET Core 2.0 application and I would like to map any path that does not start with /api to just reexecute to the root path. I added the below but doesn't seem to work: app.MapWhen( c => !c.Request.Path.StartsWithSegments("/api", StringComparison.OrdinalIgnoreCase), a => a.UseStatusCodePagesWithReExecute("/") ); Not using MapWhen() and just using app.UseStatusCodePagesWithReExecute("/") works for all paths not root. Just want to add filtering for all paths not root and not /api .