Redirect to EXE with Parallel Parallel and IE6 / 7 options

Hello!

I scratch my head wondering why when I do the following:

Response.Redirect(@"http://www.example.com/file.exe?id=12345");

      

Both IE6 and IE7 download the file as a "file" (no extension), but Firefox, Opera, Google Chrome and Safari have no problem downloading the file as "file.exe".

Any idea what the IE6 / 7 problem is and how can I fix it?

+1


source to share


3 answers


Have you tried setting the correct content type in the response headers? For example:



Content-Type: application/octet-stream
Content-Disposition: attachment; filename="file.exe"

      

+2


source


You may have to remotely get the file size and add it to the Content-Length in the header section.



0


source


If you are using fiddler2 ( http://www.fiddler2.com/fiddler2/ ) you can see exactly what headers are sent in IE, which can help you debug.

Perhaps you can post the headers received here?

I doubt adding Content-Type and Content-Disposition before the redirect will have any impact, as the browser sees the redirect header and makes a completely new HTTP request to the redirected URL, which will be a completely different set of headers.

However, you can try Server.Transfer, which is a server side redirect, something like the following:

Response.Clear(); //In case your .aspx page has already written some html content
Response.AddHeader("Content-Type", "application/octet-stream");
string disp = String.Format("attachment; filename={0}", fileName); // fileName = file.exe
Response.AddHeader("Content-Disposition", disp);

Server.Transfer(@"http://www.example.com/file.exe?id=12345");

      

Or, alternatively, use Response.BinaryWrite:

Response.Clear(); //In case your .aspx page has already written some html content
byte[] exeContent = ... //read the content of the .exe into a byte[]

Response.AddHeader("Content-Type", "application/octet-stream");
string disp = String.Format("attachment; filename={0}", fileName); // fileName = file.exe
Response.AddHeader("Content-Disposition", disp);

Response.BinaryWrite(exeContent);

      

0


source







All Articles