I have a ASP.NET Core 3.1 web server and I'm receiving post requests like this:
[HttpPost("/api/loginweb")]
public IActionResult loginWeb([FromHeader(Name = "usuario")] String usuario, [FromHeader(Name = "pass")] String pass)
{
The problem I have is sending the ñ character on a header:
But, when I receive it I get:
You can right-click
barñfoo in postman, choose EncodeURlComponent option, and then when the data of usuario
is received, use HttpUtility.UrlDecode() method to get the string containing special characters.
[HttpPost("/api/loginweb")]
public IActionResult loginWeb([FromHeader(Name = "usuario")] string usuario, [FromHeader(Name = "pass")] string pass)
{
usuario = HttpUtility.UrlDecode(usuario);
return Ok();
}
Here is the process to test:
I have found a thread which explains the reason of this phenomena. You can have a look for this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.