views:

20

answers:

1

I'm running ASP.NET on an IIS6 server. Right now the server is set up to compress dynamically generated content, mainly to reduce the page size of ASPX files that are being retrieved.

Once of the ASPX files has the following bit of code, used to fetch a file from the database and send it to the user:

Response.Clear();
Response.Buffer = true;
Response.ContentType = Document.MimeType;
Response.AddHeader("content-disposition", "attachment;filename=\"" + Document.Filename + Document.Extension + "\"");
Response.AddHeader("content-length", Document.FileSizeBytes.ToString());

byte[] docBinary = Document.GetBinary();
Response.BinaryWrite(docBinary);

The download itself works perfectly. However, the person downloading the file doesn't get a progress bar, which is incredibly annoying.

From what research I've been doing, it seems that when IIS sets the transfer-encoding to chunked when compressing dynamic content, which removes the content-length header as it violates the HTTP1.1 standard when doing that.

What's the best way to get around this without turning dynamic compression off at the server level? Is there a way through ASP.NET to programatically turn off compression for this response? Is there a better way to go about doing things?

A: 

You can turn on/off compression at the site or folder level by modifying the metabase. For more information see:

Enabling HTTP Compression (IIS 6.0)

Scroll down to: "To enable HTTP Compression for Individual Sites and Site Elements"

To do this you need elevated rights (Administrator at least).

You might have to place the download page in it's own folder and turn off compression at that level so as not to affect other parts of the site.

I have to admit I've not tried this but it's what I'd attempt first.

Kev