Launching Applications from ASP.NET

Joined
Feb 12, 2006
Messages
18
Location
Australia
Programming Experience
10+
I can launch an application from VB.NET (VS2003) but the same code merely refreshes the browser window in ASP.NET, for example:

Process.Start ("C:\Inetpub\wwwroot\ScottQualityControl\QP_050_files\ArtefactionCorporateProfile.pdf")

NB: This is all on a single line in the application

The file is physically in the correct place, the correct namespaces have been declared, i.e.

Imports System
Imports System.Diagnostics
Imports System.ComponentModel

What is different about launching an application from a Windows Client and an ASPX page?
 
The location of the file has to be in a place where the browser can get to it. And you'll want to use the URL (not the absolute path) to the file.

Secondly, if you are trying to oprn the file for the web user to read, just supply a link to it and don't force it. They may not have a PDF reader installed, and I think the Process.Start runs the process on the WEb server, not the client.

-tg
 
First Problem Solved

Doh!

Forward slashes ("/") work a whole lot better than backslashes ("\") in URLs so that part of the problem has been resolved. I can now successfully open PDFs, DOCs, Text files and, of course, redirect to other aspx pages.

I am only running this application as an Intranet so am prefixing the URL (retrieved from a file) with http://localhost/ before adding the remaining part of the address.

I'm not sure how this would work if I wanted to place the application on the web, presumably I'd change the prefix to something like http://www.artefaction.net/ before adding the remainder of the address (this isn't a problem I need to resolve today).
 
Yeah, that'll do it all right (/ vs \) .... And yes, as long as you change the prefix to the right URL address, it should be OK.

-tg
 
Running Process.Start in your code-behind of the web page will cause the process to launch on the web server. Because you are running your development website locally you will see the application launch, but as soon as you publish your code to a remote webserver, you will not see the process launch because it will have launched on the remote server.

If you want to launch a process on the client, you have to use Javascript or VBScript which is running on the client machine inside of the web browser. This would be done using the CreateObject() method. Scripting would have to be enabled on the client and there is also security issues w/this. Usually you will not be allowed to do this, unless there is a special case, like the httpResponse objects used for AJAX.

The other option is simply to send the .PDF file to the user who will be prompted to open/save.
 
Back
Top