Error downloading file with Firefox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there!

I'm trying to download a file in my asp.net web, but when downloading it
from a Firefox browser, instead of downloading the example.exe file, it's
downloading example.exe.htm. My code is the following:

string localfile = MyComponent.DownloadMyExe(index);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
Regex.Replace(localfile, @"\\\\(\w)*\\(\w)*\\(\w)*\\(?<Name>)*", "${Name}"));
Response.WriteFile(localfile);
Response.End();

With IE runs fine. Which is the problem, anyone knows?

Thanks a lot!
 
Tomas Martinez said:
Hi there!

I'm trying to download a file in my asp.net web, but when downloading it
from a Firefox browser, instead of downloading the example.exe file, it's
downloading example.exe.htm. My code is the following:

Just a guess here.... maybe Firefox is padding the filename with htm because
exe is not a registered MIME file type. I've run into this type of thing
before (in VB6) and what I had to do was give the file on the server a "txt"
or "zip" extension... once downloaded locally, I had to rename it to it's
correct extension.

MIME Types and File Extensions
http://www.cesis.lv/learn/CGIperl/ch15.htm
 
Hi Ken,

First, thanks for your answer, very interesting to know for future problems.
The real one was on my code. My first lines in a previous dll were these:

Response.ClearContent();
Response.ContentType="application/octet-stream";
Response.ClearHeaders();

So it couldn't know that the passed file were an exe although the extension,
sure. On the other side IE could recognize my file as an .exe, so I didn't
discovered this error until I didn't open my web on a Firefox browser. And,
finally, although I uploaded the good dll to the server, this was using the
older in the asp temp folder, so here was my problem. Thanks in anycase for
your answer, it's interesting and it's cool to know that people helps you
"por amor al arte", as we say here in Spain :)

Regads!
 
Back
Top