Skip to content

.NET8 routing with UrlEncode(url) in parameter does not work #53138

@TDroogers

Description

@TDroogers

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions