Some background info: I have a .NET Core 3.1 MVC API web application running as an Azure Web Service. One GET method expects a Base64-encoded string as part of the URL. I do not have full control over the data and so some clients happen to have data whose Base64-encoding contains a double slash. I know that URLs with double slashes are valid, so I cannot blame them either.
Now when I run my code locally in IIS Express, everything works fine. When running this code as an Azure App Service, a double slashes in the URL is reduced to a single slash, which tampers the incoming data. Here is the code of my controller (MWE):
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("[controller]")]
public class SlashController : ControllerBase
{
[HttpGet("{*parameter}")]
public string Get(string parameter)
{
return parameter;
}
}
When I access http://localhost/slash/test//test
, it returns test//test
, while when I access https://my-mwe-example-website.azurewebsites.net/slash/test//test
, it returns test/test
.
Furthermore, I can reproduce the erroneous App Service behavior locally by adding the following line to the <PropertyGroup>
section of my .csproj file:
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
Is there any way to find out the original path when the app runs as as Azure App Service Web App?
Edit:
URL-encoding doesn't help either. A GET with the path slash/test%2F%2Ftest
also returns only test/test
.
I tried different settings in Configuration -> General settings, but with no effect. Just as a shot in the dark, I tried:
- Stack: .NET and .NET Core
- Managed Pipeline: Integrated and Classic
- HTTP version: 1.1 and 2.0
- Web Sockets: On and Off