2012-10-31 38 views
1

我正在处理一些ASP.NET应用程序。在发生一些故障或错误的情况下,我得到一些奇怪的错误屏幕。错误页面显示是这样的:ASP.net中奇怪的错误屏幕应用程序

��`I�%&/m�{J�J��t��`$ؐ@�������iG#)�*��eVe][email protected]�흼��{����{����;�N'���? 
\fdl��J�ɞ!���?~|?"��Ey�')=��y6�����h��贮 
�:�V�˼n��E:��,m�Wy�����<�ӶJ�e;~|W^�`4�u�A:�f��/> 

等等....

的应用目前正处于测试阶段,因此,我已经离开了差错屏幕从web.config中可见。任何人遇到同样的问题,并得到了问题和解决方案?

回答

2

由于瑞克施特拉尔的溶液中,并且@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"); 
}