There is a SOAP web service to which the string comes. The problem with Russian characters, instead of them come question marks. The xml request itself contains the encoding:

<?xml version="1.0" encoding="utf-8" ?> 

UTF-8 and the region ru are also spelled in Globalization:

 <globalization fileEncoding='utf-8' requestEncoding='utf-8' responseEncoding='utf-8' culture='ru-RU' uiCulture='ru-RU' /> 

I found how to fix on the English stackoverflow, but somehow it looks clumsy. The point is to add the following code to global.asax in Application_BeginRequest:

 if(Request.RequestContext.HttpContext.Request.ContentType.Equals("text/xml")) { Request.RequestContext.HttpContext.Request.ContentType = "text/xml; charset=UTF-8"; } 

Can someone explain what is the reason and how can this be corrected normally? I suspect that I missed something in the settings.

    1 answer 1

    Found the reason, more precisely, even three:

    1) In the first case, the client, when sending the request, indicated in request.ContentType = "text / xml", but it was necessary "text / xml; charset = UTF-8".

    2) In the second case, ContentType was specified correctly, but the request was sent by reading the data from the xml file, but the file itself was in a different encoding.

    3) The client had request.ContentType = "text / xml; charset = UTF-8" all correct, but he passed the data without conversion to UTF8:

     byte[] contentBytes = Encoding.Default.GetBytes(body); 

    and it was necessary so:

     byte[] contentBytes = Encoding.UTF8.GetBytes(body);