'GBK' is not a supported encoding name. For information on defining a custom encoding, see the docum

.net core web工程 使用“GBK” 报如下错

'GBK' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')

解决:

1、nuget引用 System.Text.Encoding.CodePages 包

2、在使用前 先用“System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);” 注册

    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            byte[] server_ip = Encoding.GetEncoding("GBK").GetBytes(sendContentModel.ServerIp);
原文地址:https://www.cnblogs.com/xbding/p/15791280.html