Skip to content

Breaking routing behavior between net6, net7 and net8. #50773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kimbell opened this issue Sep 18, 2023 · 2 comments
Open

Breaking routing behavior between net6, net7 and net8. #50773

kimbell opened this issue Sep 18, 2023 · 2 comments
Labels

Comments

@kimbell
Copy link

kimbell commented Sep 18, 2023

This little adventure started some weeks ago as we were updating our applications from .NET6 to .NET7. We have over 150 internal apps running on .NET, so we have an internal framework that handles all the common things: complete control over the middleware pipeline being one of them.

Our framework for .NET6 was still using Startup since we needed to support old .NET Framework applications as well. For .NET7, we removed .NET Framework and moved over to minimal API's setup since that is where all the cool kids are these days. During this update we discovered a routing change that was reported as #50393, but we managed to find a workaround.

With the release on .NET8 RC1, we started updating our framework to support that, and came across the same error we had on .NET7.
The core of the problem is that if we use static files, UsePathBase and Razor pages with a match-all filter, then we never get static files. We always get the default Razor page.

I've been trying different things, and it just gets even more confusing. My main branch is running .NET7 and works with the workaround. I created a new branch where we multi-target .NET7 and .NET8; selecting .NET7 as the target framework and the code stops working.

One of the selling points for minimal api's was to move away from the ceremony and magic of MVC. Debugging this new minimal api magic isn't that much easier.

I've updated my repro with some tests that illustrate things: https://github.com/kimbell/RazorStatics

For .NET6, all tests are green
For .NET7, static file tests only work with our workaround
For .NET8, no static file tests work.

Passed!  - Failed:     0, Passed:     6, Skipped:     0, Total:     6, Duration: 361 ms - RazorStatics.Tests.dll (net6.0)
Failed!  - Failed:     2, Passed:     4, Skipped:     0, Total:     6, Duration: 273 ms - RazorStatics.Tests.dll (net7.0)
Failed!  - Failed:     4, Passed:     2, Skipped:     0, Total:     6, Duration: 320 ms - RazorStatics.Tests.dll (net8.0)
@ghost ghost added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Sep 18, 2023
@javiercn javiercn added area-hosting Includes Hosting and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Sep 18, 2023
@javiercn
Copy link
Member

This seems to be related to the interactions with the implicit registrations and the middleware defined on the pipeline.

For what its worth /{*path} will always match, so it comes down to whether UseStaticFiles gets to see an endpoint in the HttpContext (in which case it doesn't try to match) or not.

If you have a lot of customization in the pipeline, you might want to use the WebHostBuilder directly to exactly configure the pipeline as you need (and avoid all the global implicit middleware that we plug in on the streamlined approach).

@kimbell
Copy link
Author

kimbell commented Sep 19, 2023

I added an additional test in my repro where I don't set up UsePathBase() at all. Things work fine in .NET6 and .NET7, but fail in .NET8.

Code that used to work without any problems in .NET6 got worse in .NET7 and even more worse in .NET8. If this is intentional, it's a surprising behavior.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@mkArtakMSFT mkArtakMSFT added this to the 9.0-preview7 milestone Mar 12, 2024
@mkArtakMSFT mkArtakMSFT added area-routing area-hosting Includes Hosting and removed area-hosting Includes Hosting area-routing labels Jul 3, 2024
@javiercn javiercn removed their assignment Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants