MIME Type for MSI Download

M

Mark Olbert

I have an application whose installer can be downloaded from the Internet as an MSI file (by
clicking on a link). The content-type parameter is set to application/octet-stream.

Under Firefox, this works fine. However, under IE, the file is downloaded as an "unknown type", and
the file extension is stripped off.

How do I go about preserving the MSI file extension under IE?

- Mark
 
K

Ken Cox [Microsoft MVP]

Is it stripped off by IE because it is listed on that machine as a known
file extension?
 
M

Mark Olbert

Ken,

I'm confused. Why would it be stripped because it's a known extension? Why would the extension ever
be stripped?

FWIW, msi is a known extension on at least my machine (which exhibits the problem).

- Mark
 
J

Juan T. Llibre

If you're using IE 4.0, it's a problem.
The problem was fixed in IE 4.01 and later.
--------------------------------------------

From that KB article :
----------------------
CAUSE
This problem can occur if Internet Explorer 4.0 is installed
and the "Hide file extensions for known file types"
(or "Hide MS-DOS file extensions for file types
that are registered") check box is selected.

STATUS
This behavior no longer occurs
in Internet Explorer 4.01 Service Pack 1.
--------------------------------------------

That shouldn't be your problem, currently, Mark,
since at least IE 5.01 is needed to install the .Net Framework.

Why are you setting the content-type parameter at all ?

For a simple download link, you don't need to set the
content-type parameter to application/octet-stream.

My question to you is :
Why don't you use a standard HTML <a href...> tag ?

I just tried it with the WebMatrix.msi file, like this :
<a href="WebMatrix.msi">WebMatrix</a>
and it works just fine.

If you need for the file to be somewhere else,
you can change the directory path to fit your needs.

If you have special needs ( like the file being selected
dynamically instead of being a static link), there's many
ways that can be achieved.



Juan T. Llibre
ASP.NET MVP
===========
 
K

Ken Cox [Microsoft MVP]

The article is contradictory. Look at the Applies to section:

APPLIES TO
.. Microsoft Internet Explorer 1.0
.. Microsoft Internet Explorer 2.0
.. Microsoft Internet Explorer 3.0
.. Microsoft Internet Explorer 3.01
.. Microsoft Internet Explorer 3.02
.. Microsoft Internet Explorer 4.0 128-Bit Edition
.. Microsoft Internet Explorer 4.01 128-Bit Edition
.. Microsoft Internet Explorer 5.0
.. Microsoft Internet Explorer 5.01 Service Pack 3
.. Microsoft Internet Explorer 5.5 Service Pack 1
.. Microsoft Internet Explorer 3.2
.. Microsoft Internet Explorer 4.0 128-Bit Edition
.. Microsoft Internet Explorer 2.01
.. Microsoft Internet Explorer 3.0
.. Microsoft Internet Explorer 3.01
.. Microsoft Internet Explorer 3.02
.. Microsoft Internet Explorer 4.0 128-Bit Edition
.. Microsoft Internet Explorer 4.01 128-Bit Edition
.. Microsoft Internet Explorer 5.0
.. Microsoft Internet Explorer 5.01 Service Pack 3
.. Microsoft Internet Explorer 5.5 Service Pack 1



Juan T. Llibre said:
If you're using IE 4.0, it's a problem.
The problem was fixed in IE 4.01 and later.
--------------------------------------------

From that KB article :
----------------------
CAUSE
This problem can occur if Internet Explorer 4.0 is installed
and the "Hide file extensions for known file types"
(or "Hide MS-DOS file extensions for file types
that are registered") check box is selected.

STATUS
This behavior no longer occurs
in Internet Explorer 4.01 Service Pack 1.
--------------------------------------------

That shouldn't be your problem, currently, Mark,
since at least IE 5.01 is needed to install the .Net Framework.

Why are you setting the content-type parameter at all ?

For a simple download link, you don't need to set the
content-type parameter to application/octet-stream.

My question to you is :
Why don't you use a standard HTML <a href...> tag ?

I just tried it with the WebMatrix.msi file, like this :
<a href="WebMatrix.msi">WebMatrix</a>
and it works just fine.

If you need for the file to be somewhere else,
you can change the directory path to fit your needs.

If you have special needs ( like the file being selected
dynamically instead of being a static link), there's many
ways that can be achieved.



Juan T. Llibre
ASP.NET MVP
===========
Ken Cox said:
Hi Mark,

Here's an article that offers something of an explanation:

File Extensions Are Lost When Saving Files from the Internet

http://support.microsoft.com/default.aspx?scid=kb;en-us;176106

Ken
Ken,

I'm confused. Why would it be stripped because it's a known extension?
Why would the extension ever be stripped?

FWIW, msi is a known extension on at least my machine (which exhibits
the problem).

- Mark

On Sat, 15 Jan 2005 12:50:05 -0500, "Ken Cox [Microsoft MVP]"

Is it stripped off by IE because it is listed on that machine as a known
file extension?
 
J

Juan T. Llibre

I think it's the setting of the content-header.

Just using a regular HTML link works
fine for clients downloading MSI files.

I suppose that using an ASP.NET
hyperlink would work, too.



Juan T. Llibre
ASP.NET MVP
===========
 
M

Mark Olbert

Ken,

Thanx for the lead. I'll check with the client, but I'm pretty sure she has IE6 installed (she's
running an XP Home box). The article doesn't reference IE6 as having the problem. Do you know if it
still exists on that platform?

- Mark
 
M

Mark Olbert

Okay, now I'm confused. The download process is triggered by the user clicking on an ASP.NET link
button. Here is the code fragment called when the link is clicked:

if( File.Exists(toDownload) )
{
theFile = new FileInfo(toDownload);

Response.Clear();

// specify that the response is a stream that cannot be read by the
// client and must be downloaded
Response.ContentType = "application/octet-stream";

// add the header that specifies the default filename for the
// Download/SaveAs dialog
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);

// add the header that specifies the file size, so that the browser
// can show the download progress
Response.AddHeader("Content-Length", theFile.Length.ToString());

// send the file stream to the client
Response.WriteFile(theFile.FullName);

// stop the execution of this page
Response.End();
}

Is some part of this in error? Again, it works fine under Firefox running on the same platform.

And, now that I think about it, the "hide file extension" settings referred to in an earlier post
can't be the reason, because the download process truncates the extension on my development machine,
and I know for a fact that I have "show every darn file extension you can" set :) because hiding
file extensions seems like an evil and pernicious act to me :). I'm also running XP Pro SP2 and IE6+

So something else is going on here....

- Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top