1、Http Post Header 中文数据值,服务端接收Header 中文数据值乱码问题:
客户端:
Encoding utf8Encoding = Encoding.GetEncoding("utf-8");
string utf8FileName = HttpUtility.UrlEncode(fileName, utf8Encoding); // Encoding.UTF8.GetString(Encoding.Default.GetBytes(fileName)); //不可以会是乱码,不是URL格式
webRequest.Headers.Add("FileName", utf8FileName);
服务端须转换:
FileName = java.net.URLDecoder.decode(FileName,"utf-8");
时间: 2024-10-06 10:46:22