Content Length Is Shown as Not Known When Downloading Using TransmitFile ASP .NET Method

I was trying to enable downloading of a file from an ASP .NET page, using TransmitFile method, and using content-disposition response header. Everything was right when testing on localhost, but when deploying to IIS on a Windows Server 2003 box, even that the file could be successfully downloaded, the file size was displayed as “Not Known” during the download process.

First, I was incorretcly trying to resolve the problem by applying a content-length header to the response, but this was NOT the correct solution (it didn’t work, but it’s also not logically correct), as the actual (not known) content-length is actually overwritten by ASP .NET itself (this is by the ASP .NET design, and therefore expected behavior).

The resolution was to disable application file compression on IIS, on the Windows Server 2003 machine:

  1. In IIS Manager, expand the local computer, right-click the Web Sites folder, and then click Properties.
  2. Click the Service tab, and in the HTTP compression section, unselect the Compress application files check box to disable dynamic compression.

Update: Note that if you do disable dynamic compression, depending on what other roles your Windows Server machine has, some client-server communication may not work or may need to be reconfigured (for example, Outlook client connection to an Exchange Server installed on the same machine). Be extra careful and do test all the applications that rely on server connections when you apply the change. Or, you may want to apply the change (disable application files compression) only for a specific Web site instead.

About Sorin Dolha

My passion is software development, but I also like physics.
This entry was posted in Computers and Internet. Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s