由於瑞克施特拉爾的溶液中,並且@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