Skip to content

Blazor (Server) route does not match when complex characters are in the url #53262

@Sebazzz

Description

@Sebazzz

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Kind-of a regression of #16840 (fixed in PR #26769), a route is defined for a page with a placeholder. However, when there are weird characters in the URL it doesn't match the route for the page. This worked in .NET 7 and is broken in .NET 8.

In .NET 8 the route does not match:

dbug: Microsoft.AspNetCore.Components.Routing.Router[3]
      Navigating to non-component URI 'http://localhost:5110/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' in response to path '/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path '/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route

Expected Behavior

In .NET 7 the route matches and this is logged:

dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/!%40%23%24%25%5E%26*()_%2B-%3D[]%7B%7D//|%3B'%3A/%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/!%40%23%24%25%5E%26*()_%2B-%3D[]%7B%7D//|%3B'%3A/%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route

Steps To Reproduce

Given a component with this route:

@page "/project/{projectCode}/ruimte/{publicAreaId}/bron/{sourceCode}/bewerken"

And URL:

/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken

The sourceCode part !@#$%^&*()_+-=[]{}\\|;':\">?./ is url-encoded.

Full repro: dotnet-bug.zip

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

.NET 7.0:

net7-0

.NET 8.0, identical code:

net8-0

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