Nate Silva

May 05 2008

When downloading an .EXE file in IE, it loses its file extension

Internet Explorer has odd behavior when downloading certain files. If you have an .exe file, but it’s served by a URL with a query string, IE will lose the file extension.

An example might be easier to understand.

Let’s say you’re using Amazon S3 to serve your downloads. You’ve got a file, myfile.exe, that your customer wants to download. Using S3 you generate a URL that allows them to download the file, and you can set the URL to expire after a certain time. The resulting URL might look like this:

https://nate.s3.amazonaws.com:443/myfile.exe?Expires=1210007779&AWSAccessKeyId=1HHMQMPRV9GFWH6BTP82 &Signature=5dfcG5OC9BSkDFSzjxQGjlbKNi0%3D

Notice that the URL contains /myfile.exe followed by some query string parameters (everything after the question mark is the query string parameters).

Most web browsers will interpret this as being a request for the file myfile.exe.

Internet Explorer will interpret this as being a request for a web page served by an application on the server called myfile.exe. The resulting download will be called myfile (instead of myfile.exe), which doesn’t work.

There’s a workaround, which is to add the filename to the end of the query string, like this:

https://nate.s3.amazonaws.com:443/myfile.exe?Expires=1210007779&AWSAccessKeyId=1HHMQMPRV9GFWH6BTP82 &Signature=5dfcG5OC9BSkDFSzjxQGjlbKNi0%3D&filename=myfile.exe

There’s no reason in the HTTP standard why this should be required; it’s just a way that Microsoft developed to work around the bug in IE.

More information, including Microsoft’s creative interpretation of the HTTP standard, can be found in Knowledge Base Article 221805. The article says the bug is fixed, except not for .exe and .dll files! This is another case of inconsistent behavior in IE.

Page 1 of 1