download a file in a background without Save As

  • Thread starter Thread starter sunilj20
  • Start date Start date
S

sunilj20

Hello,

I have a requirement wherein, a user clicks on a file name in an
ASP.NET web application, and the file should automatically be
downloaded (Without showing the "Open", "Save As") in the local machine
at a pre defined path (path defined in the registry), and launch the
file in its associated application.

I think this can be done through ActiveX Controls, but i dont know how
to create ActiveX controls in .NET??

Can anyone give me any suggestions as to how one can achieve this??

Thanks in advance for help

Cheers

Sunil
 
It will require some client side setup as this is not possible by default
due to security.

You could create an ActiveX control, a.NET control or a Java applet. It's no
use IMO to create an ActiveX control in .NET. As you'll require anyway .NET
client side just create a .NET control (.NET allows to expose a .NET control
as an ActiveX control but doesn't allow to create a "plain old" ActiveX
control).

See for example : http://windowsforms.net/articles/iesourcing.aspx

Before starting you may want to quickly check the impact it will have to see
if it's worth (I would let the user choose between opening and saving)...

Patrice
 
Heyy Patrice,

Thanks for your suggestions. I will go through the link you have sent
me. Well there are 2 things here -
1) I want the file which the user clicks on, to be saved in the local
machine file store, as i have my own desktop application accessing it.
(The file extension is mapped to my application by default, so no
problems as File open will launch my desktop application)
So the problem is that if i show the traditional "Open" & "Save As", i
have no gurantee that the user will store in the local file store.
Secondly it will be stupid to show the user "Save the file in
C:\Program Files\MyApp\Workfiles", as this will not gurantee that the
user will do that, 99% of them will store on the desktop :)
2) The reason i came to a conclusion of a Activex is for the fact that
-
a) Activex Control is in the local machine and hence has access to the
local machine registry or the local machine file path
b) Since i am making the desktop application as well, i can package
the Activex Control, this will ensure that the control is signed and
in place in the target machine.
c) I have seen a similar kind of thing in another site, which uses
<object> tag, which i think is an ActiveX control.

Can you suggest in this scenario??

Thanks for your help

Cheers

Sunil
 
Hi Neo,

If you have your application registered with the OS to handle this file
extension, then you should be able to setup your file as a Mime type in the
browser. Then, when the user clicks on the link, it should prompt them to
open the file with your application. Also, if you app is registered with the
OS, it doesn't matter where they save the file because as soon as they
double-click it (from any location), it should launch your application.

If setup correctly, it doesn't matter where they save it as your desktop app
should be making use of command line arguments to determine where a file is
located rather then hard-coded or assumed paths. (This would be a
best-practice senario: "Open %1" and then your app should be able to find %1
as the full path to the file from the command line.)

IMHO, ActiveX controls should have been phased out years ago. Aside from the
security issues (which are on a list longer than that of most of the Windows
OS bug lists). Also, unless you are 100% certain that your users are using
IE, then an ActiveX control is going to be worthless to people using other
browsers. (At my company, we don't have a standardized browser, anyone can
use whatever their heart desires, which makes internal development
interesting, to say the least.)

I would recommend fleshing out your desktop application to make better use
of the %1 command line vars and avoid tinkering with the browser and with
ActiveX controls.

HTH (and sorry about the rant and flame... lol)
~d
 
Hello DotNetCoder,

Thanks for your inputs. Well if the file storage was not so
imperative, then i think we could have done just the "Open", "Save As"
thingie. Since the requirement is that the user works on the
downloaded file, generates another set of files and uploads all the
files again, i think i need to store the file locally in a predefined
path/folder. the files are generated automatically at the location
where the original file is stored.

Setting it up as a mime type in the browser, would not help much in
this case as it is essential for me to have the file at a known
location.

Cheers

Neo (a.k.a Sunil)
 
Back
Top