[RESOLVED]Automatically open file after downloading


I am working on MVC WEB application, where in, on button click a file gets documented (MS word file).

It asks for location to save to the save.

once the file gets downloaded. User need to click on file to open it.

I want to open file directly once it gets saved on client machine.  No need to click on file for opening same. 

Can this be possible ?  using Jquery or something

Thanks in advance   

If the user want to open the document they’ll select the open option rather than the download, or they’ll select to open the file after it has been downloaded.  You can’t dictate these kind of things from your code.


Can this be possible ?



using Jquery or something

Not with anything. 

Browsers do not permit this kind of behaviour for security reasons. It would be irresponsible for browser vendors to allow files to be opened automatically and saved on target machines. The files could contain malware.


Which browser? You should be able to force a dialog that will ask to save (seems to be your current scenario) or to open the file.

You can’t force opening directly the file without any user confirmation or at least if I remember it is (was ?) possible only if the user choosed this option (and it is/was quite buried in the Windows UI).

You set the content-disposition to inline for open or attachment for save. Unless you site is marked as trusted, there will be a warning dialog.

Leave a Reply