Home > Net >  How to get unicode string from http request header in ASP.NET Core 6 similar to ASP.NET MVC?
How to get unicode string from http request header in ASP.NET Core 6 similar to ASP.NET MVC?

Time:03-28

I have two similar controllers in ASP.NET MVC and ASP.NET Core 6 projects that both run through IIS. When I request the first one, the custom http request header containing unicode characters is parsed correctly:

enter image description here

When I request the second one, instead of unicode characters, I get question marks (65533-symbol):

enter image description here

How can I get the same result in the second case as in the first?

CodePudding user response:

UPDATE

After consulting the official documentation, I regret to tell you that adding Bulgarian to the Http Header directly is not supported. (I googled it and found that it might be Bulgarian language)

enter image description here

You can enter image description here

enter image description here

enter image description here


Please use System.Web.HttpUtility.UrlEncode method to encode the characters.

var desc22=HttpContext.Request.Headers["Description"];
string desc22_ncode1 = System.Web.HttpUtility.UrlEncode(text, System.Text.Encoding.UTF8);
return ...

Related Post

1. File format name downloads in foreign language not supported on Azure

2. Encoding issues in Azure WebApps

  • Related