Garbled error page output using Gzip in ASP.NET / IIS7

后端 未结 2 903
广开言路
广开言路 2021-02-02 15:11

I\'ve implemented Rick Strahl\'s GZipEncodePage method on my site and it works great for the site itself. However, when my code throws an exception the \"Server Error\" page lo

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-02 15:38

    In my case I put this in the my basepage class like so:

    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;
        }
    }
    

提交回复
热议问题