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 7495325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:02:07+00:00 2026-05-29T18:02:07+00:00

My web app generates a CSV file on the fly, but whenever I use

  • 0

My web app generates a CSV file on the fly, but whenever I use GZIP compression, the download fails:

HTTP/1.1 200 OK
Cache-Control: private, s-maxage=0,no-store, no-cache
Transfer-Encoding: chunked
Content-Type: text/csv;charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
Content-Disposition: attachment;filename="filename.csv"
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
p3p: CP="CAO PSA OUR"
Date: Fri, 03 Feb 2012 11:27:27 GMT

The download appears as “Interrupted” in Google Chrome, and in Internet Explorer appears an error that says “Content decoding has failed” .

HTTP/1.1 200 OK
Cache-Control: private, s-maxage=0,no-store, no-cache
Transfer-Encoding: chunked
Content-Type: text/csv;charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
Content-Disposition: attachment;filename="filename.csv"
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
p3p: CP="CAO PSA OUR"
Date: Fri, 03 Feb 2012 11:23:30 GMT

The solution is disabling compression on that action, but… why does this happen?

Cheers.

UPDATE: The compression filter that I use:

public class EnableCompressionAttribute : ActionFilterAttribute
{
    const CompressionMode compress = CompressionMode.Compress;
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (filterContext.IsChildAction)
            return;

        var actionAttributes = filterContext.ActionDescriptor.GetCustomAttributes(true);
        if (actionAttributes != null && actionAttributes.Any(attr => attr is SkipCompressionAttribute))
            return;

        HttpRequestBase request = filterContext.HttpContext.Request;
        HttpResponseBase response = filterContext.HttpContext.Response;
        String acceptEncoding = request.Headers["Accept-Encoding"];

        if (acceptEncoding == null || response.Filter == null)
            return;

        if (acceptEncoding.ToLower().Contains("gzip"))
        {
            response.Filter = new GZipStream(response.Filter, compress);
            response.AppendHeader("Content-Encoding", "gzip");
            response.AppendHeader("Vary", "Accept-Encoding");
        }
        else if (acceptEncoding.ToLower().Contains("deflate"))
        {
            response.Filter = new DeflateStream(response.Filter, compress);
            response.AppendHeader("Content-Encoding", "deflate");
            response.AppendHeader("Vary", "Accept-Encoding");
        }
    }
}
  • 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-29T18:02:09+00:00Added an answer on May 29, 2026 at 6:02 pm

    Try:

    Response.Headers.Remove("Content-Encoding");
    Response.AppendHeader("Content-Encoding", "gzip");
    

    Another problem may be the caching: what if a client accepts compressed content, but the next client doesn’t, and the server cached the compressed data? what the second client will get? A cached compressed page that won’t decode!

    To fix that, add another method:

    public override string GetVaryByCustomString(HttpContext context, string custom)
    {
        if (custom == "GZIP")
        {
            string acceptEncoding = HttpContext.Current.Response.Headers["Content-Encoding"];
    
            if (string.IsNullOrEmpty(acceptEncoding))
                return "";
            else if (acceptEncoding.Contains("gzip"))
                return "GZIP";
            else if (acceptEncoding.Contains("deflate"))
                return "DEFLATE";
    
            return "";
        }
    
        return base.GetVaryByCustomString(context, custom);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the web app I am currently working on generates a PDF file and sends
I've inherited a VB.net project that generates 2 DLLS: one for the web app,
The requirenment is to the siverlight web UI will define the CSV file format
I have a PHP web app that generates a somewhat complex report from our
I have a web app that takes in variables from the client and generates
I'm building a web app that coaches people to rise earlier, it generates a
Web app I'm working on generates HTML using Velocity templates. Problem is that using
I have small web app that generate PDF files as a report. I'm trying
I am working on a web app that will generate an NxN grid based
I'm building a new web app that has a requirement to generate an internal

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.