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

Posted on 2009-04-03
Medium Priority
Last Modified: 2012-05-06
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.
Question by:dlsimic
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2

Author Comment

ID: 24064569
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.
LVL 27

Expert Comment

ID: 24064675
dlsimic: I'm running out of ideas myself. Let's see what the separate process does.
Technology Partners: 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!

LVL 14

Expert Comment

ID: 24065857
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?

Author Comment

ID: 24067109
When they click a button on the intranet website it must open a jpg/tiff on the client machine in their default windows application.
LVL 14

Expert Comment

ID: 24071765
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.

Accepted Solution

dlsimic earned 0 total points
ID: 24079393
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);

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question