aspnetcore: .NET8 routing with UrlEncode(url) in parameter does not work

Is there an existing issue for this?

  • I have searched the existing issues

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)

var returnUrl = HttpUtility.UrlEncode("https://localhost:5001/authentication/login-callback");
Navigation.NavigateTo($"{url}/login/{returnUrl}");

returnUrl == https%3a%2f%2flocalhost%3a5001%2fauthentication%2flogin-callback

project B

@page "/login/{LoginUrl}"

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 404~

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

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?

@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.

https://github.com/dotnet/aspnetcore/pull/53470 This is now fixed in main and we’ll probably backport it to 8.0 in a future patch