-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
.NET8 routing with UrlEncode(url) in parameter does not work #53138
Comments
Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content. |
@javiercn I created TDroogers/BugUrlRouting to reproduce this issue. |
I have added a second project in .NET7 in the same solution to prove the issue is new in .NET 8 |
I did some more investigation and the problem is that the encoded slash TDroogers/BugUrlRouting@e9ee2fb My guess is that something goes wrong in the order of decoding the url and the decision what path to use. |
I can also confirm that I have run into this same issue after upgrading my .NET 7 Blazor Server project to .NET 8. |
This comment was marked as outdated.
This comment was marked as outdated.
@TDroogers thanks for your patience. I think I've tracked this down to this change https://github.com/dotnet/aspnetcore/blob/main/src/Components/Components/src/Routing/RouteContext.cs#L14 where we were previously splitting every segment and the URL decoding that and now we are URL decoding the entire path The previous version of the code is https://github.com/dotnet/aspnetcore/blob/771532a3a31e8df2811a6201a2d3850a4171de15/src/Components/Components/src/Routing/RouteContext.cs The key thing here is that the behavior needs to be the same between SSR (ASP.NET Routing) and whatever the Blazor router does. They share the same codebase, but it seems that some of the setup is slightly different. Hopefully the behavior matches between the old implementation and the asp.net core implementation and we can "just" fix a bug. If the behavior is different, we'll likely need to go with the new behavior, as we aren't changing ASP.NET Core routing and both routing systems (interactive and SSR) need to offer the same results. |
Removing the decoding step makes the scenario "work consistently" across all the implementations, but I suspect there's more work to do or else we will break other scenarios. SSR: Click on link -> Url: The last part/diff then seems to be that in 7.0, the parameter is decoded |
Thanks for your response! |
This was discovered when working on the issue for #53138. The regex constraint is not enabled by default on the blazor router. As a result if a route uses a regex constraint, it will work on SSR but will fail the moment the Blazor router tries to construct the route. The fix enables the regex constraint on the blazor router, unconditionally for server, and behind a feature flag for webassembly. This is because enabling the regex constraint adds +80kb to the payload due to the inclusion of the System.Text.RegularExpressions assembly.
#53470 This is now fixed in main and we'll probably backport it to 8.0 in a future patch |
@javiercn Thanks for fixing this. Do you have an idea of when that 8.0 patch will be deployed? This bug is preventing me from upgrading my project to 8.0 because a lot of my navigation encodes a return url in the querystring. |
This was discovered when working on the issue for #53138. The regex constraint is not enabled by default on the blazor router. As a result if a route uses a regex constraint, it will work on SSR but will fail the moment the Blazor router tries to construct the route. The fix enables the regex constraint on the blazor router, unconditionally for server, and behind a feature flag for webassembly. This is because enabling the regex constraint adds +80kb to the payload due to the inclusion of the System.Text.RegularExpressions assembly.
This was discovered when working on the issue for #53138. The regex constraint is not enabled by default on the blazor router. As a result if a route uses a regex constraint, it will work on SSR but will fail the moment the Blazor router tries to construct the route. The fix enables the regex constraint on the blazor router, unconditionally for server, and behind a feature flag for webassembly. This is because enabling the regex constraint adds +80kb to the payload due to the inclusion of the System.Text.RegularExpressions assembly.
This was discovered when working on the issue for #53138. The regex constraint is not enabled by default on the blazor router. As a result if a route uses a regex constraint, it will work on SSR but will fail the moment the Blazor router tries to construct the route. The fix enables the regex constraint on the blazor router, unconditionally for server, and behind a feature flag for webassembly. This is because enabling the regex constraint adds +80kb to the payload due to the inclusion of the System.Text.RegularExpressions assembly.
This was discovered when working on the issue for #53138. The regex constraint is not enabled by default on the blazor router. As a result if a route uses a regex constraint, it will work on SSR but will fail the moment the Blazor router tries to construct the route. The fix enables the regex constraint on the blazor router, unconditionally for server, and behind a feature flag for webassembly. This is because enabling the regex constraint adds +80kb to the payload due to the inclusion of the System.Text.RegularExpressions assembly.
@mtavares628 we're probably looking to including this as part of the 8.0.3 release. |
@mkArtakMSFT What are the steps for targeting the nightly build in my project? I downloaded and installed the latest nightly build of the SDK for .NET 9, but when I try to change the target on my project, .NET 9 isn't listed as an option. Is there something that I'm missing to get this running? |
Thanks for giving this a try, @mtavares628. The option doesn't show up in the VS because most probably you are not using the latest VS preview which is required for the latest preview .NET SDKs. |
Thanks @mkArtakMSFT, I was able to test it out and confirm that fix solves my problem. Is there a general time frame planned for the 8.0.3 release? |
Thanks for confirming this, @mtavares628. Most probably yes - 8.0.3. In the worst case - 8.0.4, but hopefully it won't get to that. |
Is there an existing issue for this?
Describe the bug
After updating from .NET7 (blazor server) to .NET8 the routing has broken.
On project A (still on .NET7) I forward to project B (.NET8)
returnUrl ==
https%3a%2f%2flocalhost%3a5001%2fauthentication%2flogin-callback
project B
url is not changed in the process
https://localhost:44322/login/https%3a%2f%2flocalhost%3a5001%2fauthentication%2flogin-callback
However on project B I'm now forwarded to the 404 page.
If I change {returnUrl} to a non url like "text" I get on the page and the parameter gets the "text"
Expected Behavior
Should work like in .NET7
Encoded url should be read as a parameter and not forwarded to 404
Steps To Reproduce
See Describe the bug
Exceptions (if any)
No
.NET Version
8.0.100
Anything else?
Same issue in azure after deployment in release mode.
I have also tried adding some more optional paramaters,@page "/login/{LoginUrl}/{Test1?}/{Test2?}/{Test3?}"
but I still got forwarded tot the 404The text was updated successfully, but these errors were encountered: