O'Reilly logo

ASP.NET Cookbook by Geoffrey T. LeBlond, Michael A Kittel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.2. Executing External Applications

Problem

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

Solution

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.

Example 18-3 and Example 18-4 show the relevant portion of the sample VB and C# code-behind files that illustrate this solution.

Discussion

Applications frequently must interface with other applications or systems that use different technologies. At the same time, it is not always practical 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required