diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 652bf773c..95b3f6863 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -484,13 +484,19 @@ public string get_ProxyHost() { return _proxyHost; } +#if NETCORE + private static Encoding ISO_8859_1 = Encoding.Latin1; +#else + private static Encoding ISO_8859_1 = Encoding.GetEncoding("ISO-8859-1"); +#endif + private const string AuthenticationSchemeBasic = "Basic"; public void AddAuthentication(int scheme, string realm, string user, string password) { if (scheme >= _Basic && scheme <= _Kerberos) _authCollection.Add(new GxAuthScheme(scheme, realm, user, password)); if (scheme == _Basic) { - string authHeader = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{user}:{password}")); - AddHeader(HttpHeader.AUTHORIZATION, new AuthenticationHeaderValue("Basic", authHeader).ToString()); + string authHeader = Convert.ToBase64String(ISO_8859_1.GetBytes($"{user}:{password}")); + AddHeader(HttpHeader.AUTHORIZATION, new AuthenticationHeaderValue(AuthenticationSchemeBasic, authHeader).ToString()); } } @@ -1038,7 +1044,7 @@ async Task ReadResponseDataAsync() } } } - #endif +#endif bool UseOldHttpClient(string name) { if (Config.GetValueOf("useoldhttpclient", out string useOld) && useOld.StartsWith("y", StringComparison.OrdinalIgnoreCase))