How to call External Application through ASP.NET

Well at first attempt it will sound like, what ? ASP.NET application is processed on server side, how will you get the output?. Well remember its not always that you want to run a visual application. it can be a background application like some utility. For eg: After uploading a file you want to zip it and store it on your disk. Infact any console output emitted by your application can be read and displayed back into webbrowser

You can use your System.Diagnostics namespace to interact with system processes. Here is a small tip.


string file = Server.MapPath(@"MyApp.exe");
ProcessStartInfo info = new ProcessStartInfo(file, "otherargs");
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
// Send whatever was returned through the output to the client.

Note that the ASP.NET worker process needs to have permissions to access the external application. The most simple way to ensure this is to place it under the bin folder.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s