解决 .net core基础之编码问题-System.ArgumentException: ‘gb2312‘ is not a supported encoding name

 

  在利用webClient 抓取 编码方式为 GB2312 网页    提示不支持‘gb2312‘ is not a supported encoding name

解决办法 :

1.nuget引用dll:System.Text.Encoding.CodePages

 

 

 2. startup文件中配置

//直接在starup.cs启动文件里的方法添加
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
                
     System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
}
 

 

    以上可解决 asp.net core  或 webClient 不支持 gb2312编码问题

posted on 2021-10-29 10:32  码农at突泉  阅读(1059)  评论(0)    收藏  举报