0

I have a .NET Core webapi and i deployed it to IIS. When my customer post a request with json body content that have special characters like İÇĞÜÖŞğ(turkish) this characters are not passed to application correctly in webapi controller method. For example, string of "ünite arızası" in json payload is passed like enter image description here. The customer uses UTF-8 encoding in their client but I didn't configure any encoding setting in my webapi except that I set IIS .NET Globalization Request encoding to utf-8 but it doesn't work. How can I solve the problem? thanks..

My controller method :

   [HttpPost]
   [Route("register")]
   public async Task<IssiueType> Register(Dto issue)
    { 
    
       //logic
    
       return responseDto;
    }

Dto :

   public class Dto
   {
     public string detail{get;set;}
   }

   

json content from customer :

enter image description here

enter image description here

Cem
  • 361
  • 6
  • 17
  • https://stackoverflow.com/questions/21455800/asp-net-web-api-content-encoding – Chetan Jun 16 '22 at 11:15
  • What is `İÇĞÜÖŞğ` ? I use Google, but Bing translate doesn't recognize it? – Jason Pan Jun 17 '22 at 06:57
  • [.Net core should use `.resx`.](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1#globalization-and-localization-terms) – Jason Pan Jun 17 '22 at 07:01
  • Try it in the browser or in Postman. I highly doubt you are doing anything wrong. It is probably the consumer which is doing something wrong. – Joost00719 Jun 17 '22 at 10:19
  • 1
    When i post the request from my local postman to our server, characters are passed correctly, there is no problem but it fails whenever the customer sends so you're right probably @Joost00719 – Cem Jun 17 '22 at 11:04
  • We know very well that when you develop and test locally, it works just fine. It may be related to the server's region or language, so please refer to the link below to [try it from the encoding](https://stackoverflow.com/questions/64227444/encoding-issues-in-azure-webapps/64345309#64345309). – Jason Pan Jun 20 '22 at 01:38
  • Thak you for your comments. The problem was related to the customer. I guess they configured their client parameters. There is no problem now – Cem Jun 20 '22 at 11:11

0 Answers0