In my controller I have an HTTP get method that accepts a string
[HttpGet("{token}"]
public async Task<IActionResult> GetFoo(string token)
{
//Some actine
return Ok(object);
}
If I send the below-encoded token test*test, ASP .NET will decode this token to test*test by default. But if I send test/test, it does not decode the / to /.
I can understand why ASP.NET doesn't do that as it breaks the routes.
Is there a way to disable this default behavior so I can de the decoding in my controller?
CodePudding user response:
Several test results in my side, but I don't think it's what you want.
I think if you can use this kind of parameter-receiving method?
https://localhost:44393/api/hello?token=test/Param
[HttpGet]
public string Index(string token)
{
return token;
}
CodePudding user response:
I could not find a way to disable default URL decoding in ASP.net core.
As Tiny Wang suggested above, I changed the application to send the token in the header and that fixed the problem.



