当你处理http时,返回的html的header中包含:
Content-Encoding: deflate
或
Content-Encoding: gzip
时,说明是返回的是压缩的HTML。
想要支持压缩的html的话,C#中,在发送HttpWebRequest之前,设置AutomaticDecompression为对应的参数即可:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); ...... req.Headers["Accept-Encoding"] = "gzip, deflate"; //req.AutomaticDecompression = DecompressionMethods.GZip; req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
更多解释详见: