Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Opening a file in the default windows application from ASP.NET

We are using asp.net with c# for the code behind and this web app will be only be used on our intranet, so no outside access.  How can I open a picture from a supplied network path that will not popup a dialog box.  This picture will be opened in the default windows application (PhotoShop on most machines).  

I have tried using Response.AddHeader(Content-Disposition, inline; filename= + file.fullpath);.  The problem with this is it only opens it in the current web page.  

I have used Response.AddHeader(Content-Disposition, attachment; filename= + file.fullpath);.  This however, open a dialog box (not acceptable); also I have read that the application opening the file would not actually know the location of the file but just have a copy in memory.  

Is there an easy way to launch a file (jpg/tiff) in the default windows application assigned for that file type.
0
dlsimic
Asked:
dlsimic
  • 3
  • 2
  • 2
1 Solution
 
dlsimicAuthor Commented:
We tried the suggestion in the first link and while running in debug mode on devlopment machine it works fine.  However, nothing happens when we release the code to the webserver.  We checked both the webserver and client machine and also viewed task manager.  Monday we will try making a windows service, dll or some other windows application that we will call from the web app to launch the program.  Let me know if you have any ideas where we won't need to create a seperate process on the client machine.
0
 
nmarunCommented:
dlsimic: I'm running out of ideas myself. Let's see what the separate process does.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jjardineCommented:
The idea of the process class will not work in your situation as it sounds like you are trying to get the image to open in the default program on the client's machine, not on the web server.   It is tough to control the client computer to make the web browser open up documents in their default programs.   I may be totally off on what you are trying to do.  Can you clarify where you want the to be viewable, on the client or on the server?
0
 
dlsimicAuthor Commented:
When they click a button on the intranet website it must open a jpg/tiff on the client machine in their default windows application.
0
 
jjardineCommented:
I think the only way you could do this is to have a special page that you direct them to and change the content type to the type you want to give them.  an example would be a word doc or excel.  This should then ask them to open or save the file.  I don't think you cna force it into a default application without a prompt for open or save.
0
 
dlsimicAuthor Commented:
In case someone else is looking how to do this; here is how we solved our problem.

function OpenImage(path) {
                var imagepath = path.innerText;
                imagepath.replace('\\', '/');
                var oShell = new ActiveXObject("WScript.Shell");
                oShell.run('"' + imagepath + '"', 1);
            }
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now