[英]Garbled error page output using Gzip in ASP.NET / IIS7
我在我的網站上實現了Rick Strahl的GZipEncodePage方法,它對網站本身很有用。 但是,當我的代碼拋出異常時,“服務器錯誤”頁面看起來像這樣:
(來源: x01.co.uk )
我試圖掛鈎到Application_Error
,試圖刪除GZip標頭,但無濟於事。 如何在出錯時反轉GZipping?
我明白這個問題確實已經過時了。
在Application_Error上,從Response中刪除過濾器,如下所示
protected void Application_Error(Object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
app.Response.Filter = null;
}
希望這可以幫助任何人。
在我的情況下,我把它放在我的基頁類中,如下所示:
public class BasePage : System.Web.UI.Page
{
protected override void OnError(EventArgs e)
{
base.OnError(e);
System.Web.HttpContext context = System.Web.HttpContext.Current;
if (context != null && context.Response.Filter != null)
context.Response.Filter = null;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.