由于瑞克施特拉尔的溶液中,并且@Andrew Sklyarevsky用于参照:d
参考而完整描述:http://www.west-wind.com/weblog/posts/2011/May/02/ASPNET-GZip-Encoding-Caveats
我解决了问题,并且因此溶液中,在添加以下代码来Global.asax
:
protected void Application_Error(object sender, EventArgs e)
{
// Remove any special filtering especially GZip filtering
Response.Filter = null;
…
}
甚至更好
protected void Application_PreSendRequestHeaders()
{
// ensure that if GZip/Deflate Encoding is applied that headers are set
// also works when error occurs if filters are still active
HttpResponse response = HttpContext.Current.Response;
if (response.Filter is GZipStream && response.Headers["Content-encoding"] != "gzip")
response.AppendHeader("Content-encoding", "gzip");
else if (response.Filter is DeflateStream && response.Headers["Content-encoding"] != "deflate")
response.AppendHeader("Content-encoding", "deflate");
}
是的,您说得对,我正在使用HTTP压缩(GZIP),并感谢解决方案。我非常感谢你的帮助。 – Cyberpks