Aspnetcore.docs: Document that [FromRoute] does not unescape %2F

Created on 28 Apr 2018  Â·  4Comments  Â·  Source: dotnet/AspNetCore.Docs

Query string parameters are completely unescaped, but %2F from the route parameters are not unescaped to /. Not sure if this is the correct page, but this definitely needs to be documented somewhere.

Original discussion: aspnet/Mvc#4599


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms

All 4 comments

Per @ryanbrandenburg

the guidance would be not to use [FromRoute] on any values which are likely to contain %2f (/)
and instead use [FromQuery] which will give you an entirely URL decoded string

@gldraphael is that your understanding of what should be added?

That's a good recommendation.
I think it's also important to state that %2Fs will not be unescaped to /, because there are other ways to handle it if [FromRoute] is desired.

I think the IIS behaviour must also be documented.

So

  1. [FromRoute] does not decode (or unescape) %2F to /.
  2. Exception: when the app is hosted in IIS, IIS decodes the %2Fs.

PS: I haven't tested the IIS behavior.

@gldraphael we'd rather not document the exception.

Was this page helpful?
0 / 5 - 0 ratings