• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP file download button

AgentZap

Senior member
So I have a download button on my C# asp form. Essentially it uses

Response.Redirect (fileNameHere);

to download the file. The problem with this method is that it tries to display the file in the browser. I would rather it give the user a Save As dialogue. What method should I call instead?
 
I believe that's totally up to the browser, and it makes its decision based on the mime type your server reports. If it knows how to view it, it will try.

What you'd want to do is somehow configure iis to report a different mime-type for those files. Maybe you can just do it for files in a certain location, maybe you have to change it for every file of a certain extension for the whole server. A way that takes a little more work but is more controllable is, instead of redirecting the response, set the mime-type by hand, open the file and stream it out of the response. I suspect that could lead to some sluggish performance if you are under particularly heavy load though.
 
My professor mentioned there may be some kind of "javascript" solution for this. Anyone run across anything like that?
 
use webbrowser control..

Friend WithEvents web1 as AxSHDocVw.AxWebBrowser
in click event
web1.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVEAS)
 
Back
Top