Forcing Save target as... dialog

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

Guest

Hi and thanks in advanced for you help. I am working on a file-distribution
asp.net application. Users click on a custom grid column to download files
stored on a SQL DB. The client does not want to open the file in the browser,
so how can I either:
1. Display the Save Target as dialog box to download the a file when the
file is in memory using the WebFileResponse class.
2. or simulate the right click (Save Target) from a hyperlink to a physical
file.

Thank you.
 
The user and browser are ultimately in charge of what happens to the file on
the client side. You have very limited control from the server side unless
you run some thick client side code such as an ActiveX control.

One possible solution:
If you zip the file, it could not be opened directly.
Well the zip file could be opened directly, but it would be a separate step
if they wanted to open the file inside the zip file, which would already be
on their hard drive by that point.
Not sure if this might meet your requirements or not.
 
1. Display the Save Target as dialog box to download the a file when the
file is in memory using the WebFileResponse class.

WebFileResponse?

I'm not familiar with that. The basic concept, though, is that you need to
stream the file to the browser as opposed to letting the end-user click on
the link itself.
2. or simulate the right click (Save Target) from a hyperlink to a physical
file.

That's a browser function that you can't control from the server.

Personally, I find the best solution is user-education. Put a disclaimer at
the top of the page:

"To download these files, right-click the link and choose 'save as'"

-Darrel
 
Steve said:
The user and browser are ultimately in charge of what happens to the file on
the client side. You have very limited control from the server side unless
you run some thick client side code such as an ActiveX control.

One possible solution:
If you zip the file, it could not be opened directly.
Well the zip file could be opened directly, but it would be a separate step
if they wanted to open the file inside the zip file, which would already be
on their hard drive by that point.
Not sure if this might meet your requirements or not.

What's wrong with the HTTP Content-Disposition: Attachment header?
 
Thank you all for the responses. The client has agreed to educate the users
and to use an encryption mechanism which will force users to save the file.
 
Back
Top