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

  • SEARCH
  • Home
  • 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 7658207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:10:18+00:00 2026-05-31T13:10:18+00:00

I have some doubts about this server response stream compression on MVC. Actually im

  • 0

I have some doubts about this server response stream compression on MVC. Actually im using my own action filter attribute for compress.

i attached this CompressFilter into my “Home” action of my HomeController that loads the whole home page, but when i check on firebug i dont see the content-encoding:gzip, even the size is too high 18 KBytes. The url is http://goo.gl/5v5yD and this is the request/response headers:

Response headers
-----------------
Date    Sat, 17 Mar 2012 18:58:49 GMT
Server  Microsoft-IIS/6.0
X-Powered-By    ASP.NET
X-AspNet-Version    4.0.30319
X-AspNetMvc-Version 3.0
Cache-Control   private, max-age=43200
Expires Sun, 18 Mar 2012 06:58:48 GMT
Last-Modified   Sat, 17 Mar 2012 18:58:48 GMT
Content-Type    text/html; charset=utf-8
Transfer-Encoding   chunked

Request headers
-----------------
User-Agent  Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,q=0.8
Accept-Language es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive
Cookie  __utma=72740111.1981468378.1331490472.1331490472.1331490472.1; __utmz=72740111.1331490472.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

This is the code of my compression filter:

public class CompressionFilter : ActionFilterAttribute
{
        const CompressionMode compress = CompressionMode.Compress;
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpRequestBase request = filterContext.HttpContext.Request;
            string acceptEncoding = request.Headers["Accept-Encoding"];
            if (string.IsNullOrEmpty(acceptEncoding)) return;
            acceptEncoding = acceptEncoding.ToUpperInvariant();
            HttpResponseBase response = filterContext.HttpContext.Response;
            if (acceptEncoding.Contains("GZIP"))
            {
                response.AppendHeader("Content-encoding", "gzip");
                response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
            }
            else if (acceptEncoding.Contains("DEFLATE"))
            {
                response.AppendHeader("Content-encoding", "deflate");
                response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
            }
        }
}

Do you know why is not working the compression? im start thinking that maybe is better to try to compress the response using an HttpFilter instead an ActionFilter.

  • 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-31T13:10:18+00:00Added an answer on May 31, 2026 at 1:10 pm

    Are you sure? Did you fix it? Maybe your page wasn’t refreshed. Ctrl-F5 will do a full refresh. I get the correct response.

    FireFox FireBug:

    Date    Sat, 17 Mar 2012 19:29:58 GMT
    Server  Microsoft-IIS/6.0
    X-Powered-By    ASP.NET
    X-AspNet-Version    4.0.30319
    X-AspNetMvc-Version 3.0
    Content-Encoding    gzip
    Cache-Control   private, max-age=43200
    Expires Sun, 18 Mar 2012 07:29:58 GMT
    Last-Modified   Sat, 17 Mar 2012 19:29:58 GMT
    Content-Type    text/html; charset=utf-8
    Content-Length  4710
    

    Chrome Debug:

    Cache-Control:private, max-age=43200
    Content-Encoding:gzip
    Content-Length:4710
    Content-Type:text/html; charset=utf-8
    Date:Sat, 17 Mar 2012 19:27:20 GMT
    Expires:Sun, 18 Mar 2012 07:27:20 GMT
    Last-Modified:Sat, 17 Mar 2012 19:27:20 GMT
    Server:Microsoft-IIS/6.0
    X-AspNet-Version:4.0.30319
    X-AspNetMvc-Version:3.0
    X-Powered-By:ASP.NET
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some doubts about how to concatenate MvcHtmlString instances because of this information
After reading this article about validating with service layer I have some doubts. First:
I have some doubts about construction and initialization order guarantees in C++. For instance,
I have programmed an emulator, but I have some doubts about how to organizate
I have an idea of organising a game loop. I have some doubts about
I've heard recently about the Abstract Factory Pattern and have currently some doubts on
I'm developing a site and I have some doubts about the best approach to
I have some doubts, i m developing a web application in GWT using MVP
I have some doubts about the best way to do a database with passwords.
I have some simple doubts about NSOperation and GCD that I have not found

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.