Search code examples
c#.netasp.net

Starting external process from ASP.NET


I need to start an external process from my web application. This means using System.Diagnostics.ProcessStartInfo to call out and execute a console app (exe). But I then need to somehow make sure nothing went wrong during its execution and know when the application completed its work.

What's the best way to both catch all possible errors and find out when it's completed?


Solution

  • I sure hope you have control of the code for the external application or you are in for a lot of headaches. The MOST important thing to do is make sure there is no way for that application to hang and not terminate.

    You can then use the WaitForExit(), ExitCode, StandardError, StandardOut to "catch all possible errors and find out when it's completed"