Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DotNetCore API hosted via Azure App Service is stripping leading url encoded forward slash from route values. #44461

Closed
1 task done
ccromer opened this issue Oct 11, 2022 · 8 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@ccromer
Copy link

ccromer commented Oct 11, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When an ASPNetCore(net6.0) API is hosted under an Azure App Service, any route value that begins with an encoded forward slash is having the route value altered where the encoded forward slash is being removed prior to reaching the API Controller Action. I have taken this issue up with Azure support and they claim this to be a .Net Core issue, hence why I'm raising the issue here. I am unable to reproduce the issue outside of an Azure App Service. The issue only occurs when the 1st encode character is a forward slash.

Expected Behavior

To not have the route value altered by the pipeline/framework.

Steps To Reproduce

Repo: https://github.com/ccromer/AzureAppServiceAndEncodedRouteParams.git

I have published the demo API from the above repo and you can reproduce this issue by making a GET call to:

https://ccllc.azurewebsites.net/api/routes/%2Ftest

The url encoded forward slash is gone by the time it reaches the controller action where only "test" is received. Running the API locally returns a value having the %2F in the value where it can be properly url decoded.

Further inspection shows other leading url encoded characters do make it to the controller action as in:

https://ccllc.azurewebsites.net/api/routes/%40test

The difference here is that the url encoded At symbol is decoded before it reaches the controller action (which is also diff behavior when %2F is used when run locally).

Exceptions (if any)

No response

.NET Version

.Net 6 lts

Anything else?

Local
Azure
AzureWithEncodeAtSymbol

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing labels Oct 11, 2022
@javiercn
Copy link
Member

@ccromer thanks for contacting us.

You seem to be receiving the right value when querying localhost, it is only when you are on Azure App Service that you do not get the result you expect.

I suspect the reason for that is that the URL is being manipulated at some point in App Service and by the time it gets to ASP.NET Core it has already been decoded/transformed.

@javiercn javiercn added area-runtime and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing labels Oct 11, 2022
@javiercn
Copy link
Member

/cc: @Tratcher do you have further thoughts?

@ccromer
Copy link
Author

ccromer commented Oct 11, 2022 via email

@ccromer
Copy link
Author

ccromer commented Oct 12, 2022 via email

@ccromer
Copy link
Author

ccromer commented Oct 12, 2022 via email

@adityamandaleeka
Copy link
Member

@Tratcher PTAL

@crosenblatt
Copy link

Hi @ccromer - This behavior is present in App Service for backwards compatibility reasons. In order to get the raw bytes of the url exactly as they are received on the wire, you can use the header "X-Waws-Unencoded-Url".

@Tratcher Tratcher added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Oct 14, 2022
@Tratcher Tratcher removed their assignment Oct 14, 2022
@ghost ghost added the Status: Resolved label Oct 14, 2022
@ghost
Copy link

ghost commented Oct 15, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Oct 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 14, 2022
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

6 participants