Solved

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

Posted on 2009-04-03
7
342 Views
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.
0
Comment
Question by:dlsimic
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Expert Comment

by:nmarun
Comment Utility
0
 

Author Comment

by:dlsimic
Comment Utility
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
 
LVL 27

Expert Comment

by:nmarun
Comment Utility
dlsimic: I'm running out of ideas myself. Let's see what the separate process does.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 14

Expert Comment

by:jjardine
Comment Utility
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
 

Author Comment

by:dlsimic
Comment Utility
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
 
LVL 14

Expert Comment

by:jjardine
Comment Utility
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
 

Accepted Solution

by:
dlsimic earned 0 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now