Why does IIS7 ignore my content header when I use ASP.NET to stream files?

I have a simple two page website. One displays a list of files, and the other displays a file when it is clicked on a list. Everything was in order for 6 months, but now I need to move the site to Windows 2008 / IIS7. Mostly I work, but the files do not open properly (in Firefox), because the header of the content header is ignored. On-Site (IIS6) headers (using Fiddler):

HTTP/1.1 200 OK
Date: Tue, 09 Feb 2010 16:00:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Content-Disposition: attachment; filename="myfile__foo.pdf"
Content-Length: 236841
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1
Content-Type: application/octet-stream

but on an IIS7 test server I get:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 236841
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
Content-Disposition: attachment; filename="myfile__foo.pdf"

Fiddler also reports a protocol violation and says, "Content length mismatch: The response header requested 236841 bytes, but the server sent 238378 bytes."

My code is as follows:

            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=\"" + doc.DisplayFilename + "." + doc.FileExtension + "\"");
            Response.AddHeader("Content-Length", file.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.TransmitFile(file.FullName);
            Response.End();

. IIS7 , . , Classic.NET AppPool ( "" ).

IIS7 ContentType, ?

+5
1

HttpModules, /? web.config ?

2K ? ?

0

All Articles