Skip to content

Encoding a slash as %2F in URI produces unexpected escaped character in route value #2655

Closed
@aspnet-hello

Description

@aspnet-hello

From @epsitec on Saturday, December 2, 2017 11:46:30 PM

I am using RouteBuilder.MapGet() with this pattern:

address/{zip}/{town}

and I need to be able to pass it a town name which contains a / (such as Belmont/Lausanne) - which is done by using the address/1092/Belmont%2FLausanne. The routing works, however, the route value for town is returned with the string Belmont%2FLausanne.

If I use %25 or other characters which need to be escaped in the URI, they get automatically decoded by the router and returned as their corresponding characters in the route value. The only exception seems to be %2F.

In #363 someone suggested to use a Replace("%2F", "/") but this is just an ugly hack, because it would produce incorrect output for an URI containing %25 followed by 2F ("%252F" should map to "%2F" but with the hack, it would be changed to "/").

Copied from original issue: aspnet/Routing#502

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions