Skip to content

Blazor routing in .NET 8 interpreting %2f as / #53668

@danroth27

Description

@danroth27

Discussed in #53622

Originally posted by gmeister99 January 25, 2024
Hi all, I realise using an encoded forward slash (%2f) in a URL is not advised, however we have a website that uses the 'code' for a record in the URL. A code could be ABC/123. We then use it in the URL to determine what data to display on a generic page, e.g. /somepage/ABC%2f123

This used to work fine, as in the routing would go to the Blazor page with the @page directive "/somepage/{code}. But now, after upgrading the project to .NET 8, this url - /somepage/ABC%2f123 - experiences a page not found error, as it is interpreted by the Blazor routing engine as /somepage/ABC/123, which would be looking for a Blazor page with the @page directive matching "/somepage/{param1}/{param2}", which doesn't exist.

The robust solution would be to change the page to not use the 'code' in the URL, to completely avoid forward slashes. However, this page has worked for a couple of years like this without issue and is now impacting production, so I'm looking for a quick fix. Does anyone know of a setting, or some config that was changed/introduced somwhere in .NET8 that would influence routing?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions