tags:

views:

46

answers:

3

I am using:

Response.Clear();
Response.ContentType = "pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=test.pdf");
Response.WriteFile(this.txtFileName, true);            
Response.Flush();
Response.End();

which shows a prompt to download the file and the prompt by default has "Open", "Save" and "Cancel" buttons with "Cancel" selected by default.

Is it possible for me to hide the "Open" button and force users to eitehr save or cancel?

+1  A: 

No, it is impossible to hide the Open button. This behavior is (and should be) controlled by the user-agent.

Josh Stodola
+1  A: 

This is a standard dialog provided by the browser. As far as I know there is no way to mess with it and there is also no reason to do that.

You should probably try to educate your users on how to use the browser (the problem with opening a large file is quite common, usually this ends up in some temp folder anyway), instead of trying to change its behavior.

Thomas Wanner
Are you saying that when they "Open" the file, it saves it to the temp folder first? If its a video file, does it stream from this temp folder or from the server?
It depends on the type of the file and application that is used to open it, it's hard to say in general. But typically it downloads the file into the temp folder and opens it from there. For each browser there is a specific folder where you can look for these temporary files.
Thomas Wanner
A: 

You might want to try using this line instead:

Response.ContentType = "application/octet-stream";

When you set it to PDF, the browser tries to see if there is an application on the system to view PDFs (which there often is). If so, you get an open button.

I think, if you set it to the generic binary/octet-stream, the browser will only allow them to save.

slolife