21.2. Executing External Applications


You need to run an external application from your web application to perform a required operation.


Use the System.Diagnostics.Process.Start method to call your external application.

In the code-behind class for the page, use the .NET language of your choice to:

  1. Import the System.Diagnostics namespace.

  2. Create a ProcessStartInfo object, passing the name of the external application to run along with any required command-line parameters.

  3. Set the working directory to the location of the external application.

  4. Start the external application process by calling the Start method of the Process class, passing the ProcessStartInfo object.

Examples 21-3 and 21-4 show the relevant portion of the sample VB and C# codebehind files that illustrate this solution.


Applications frequently must interface with other applications or systems that use different technologies. At the same time, it may be impractical to migrate these applications to the new platforms or to provide web service wrappers to gain access to the applications. Sometimes, the only practical solution is to execute another program to perform the required operation. For example, you may have an existing application that exports data from your COBOL accounting program to a format usable by other systems. The common language runtime (CLR) provides a set of classes to support running other applications from within the .NET environment. These classes are part of the System.Diagnostics ...

Get ASP.NET 2.0 Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.