Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:02:21+00:00 2026-05-20T22:02:21+00:00

I have an HttpModule which is used to dynamically compress content from an ASP.NET

  • 0

I have an HttpModule which is used to dynamically compress content from an ASP.NET (MVC3) web application. The approach is very similar to the CompressionModule in this article (where the module applies a GZip filter to the HttpResponse and sets the correct Content-encoding header).

For one reason and another, this needs to run in classic mode, not integrated pipeline mode.

The problem I’ve got, is that on some servers that have IIS compression enabled, IIS compresses the content and then my module compresses that.

The upshot is that I get content compressed twice, with an encoding:

Content-encoding: gzip,gzip

one from IIS, and one from this line in my code:

 httpResponse.AppendHeader("Content-encoding", "gzip");

Does anyone know a way, in classic mode, that I can check to see if the content is already compressed, or if compression is enabled on the server, in order to bypass my own compression?

In pipeline mode, this check is as simple as

if (httpResponse.Headers["Content-encoding"]!= null)
{
   return;
}

i.e. check if anything has already set a content-encoding and if so, do nothing.

However, I’m stumped in classic mode. Unfortunately, accessing HttpResponse.Headers is not allowed in classic mode, so I can’t do my barrier check.

All ideas gratefully received.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:02:22+00:00Added an answer on May 20, 2026 at 10:02 pm

    Theoretically, you can use reflection to peek into HttpRequest._cacheHeaders field, where ASP.NET apparently stores all yet-to-be sent headers in classic mode:

    if (this._wr is IIS7WorkerRequest)
    {
        this.Headers.Add(HttpResponseHeader.MaybeEncodeHeader(name), HttpResponseHeader.MaybeEncodeHeader(value));
    }
    else if (flag)
    {
        if (this._cacheHeaders == null)
        {
            this._cacheHeaders = new ArrayList();
        }
        this._cacheHeaders.Add(new HttpResponseHeader(knownResponseHeaderIndex, value));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a httpmodule set up in my asp.net web application, iis7, .net 4.0
I have implemented a HttpModule in ASP.NET (framework 2.0). From my logging on the
I have two web applications in ASP.NET which are quite the same (same business
I have an ASP.net 1.1 application. In a sub-folder, I've installed blogengine.net, which is
Here's the scenario I have an ASP.NET 4.0 application which has a LOT of
In our asp.net 2.0 application we have the an HttpModule and HttpHandler. They are
I have an ASP .NET Web Forms application that makes use of the 'WebMethod'
I have just re-implemented an ASP.NET web application that uses NHibernate to use a
I have a HttpModule that redirects certain URL:s in an ASP.NET WebForms application. It
I have a custom HttpModule rewrite engine in an existing web application project that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.