title: How do I run a Console Application, capture the output and display it in a Literal?
body: <p>I see that I can start processes with System.Diagnostics.Process. I'm trying with the following code, but its not working. The page just hangs and I have to restart IIS...</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Diagnostics;
  
  public partial class VideoTest : System.Web.UI.Page
  {
      List&lt;string&gt; outputLines = new List&lt;string&gt;();
      bool exited = false;
  
      protected void Page_Load(object sender, EventArgs e)
      {
          string AppPath = Request.PhysicalApplicationPath;
  
          Process myProcess = new Process();
  
          myProcess.StartInfo.UseShellExecute = false;
          myProcess.StartInfo.FileName = AppPath + "\\bin\\ffmpeg.exe";
          myProcess.StartInfo.CreateNoWindow = true;
          myProcess.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
          myProcess.Exited += new EventHandler(ExitHandler);
          myProcess.Start();
  
          while (!exited)
          {
              // This is bad bad bad bad....
          }
  
          litTest.Text = "";
          foreach (string line in outputLines)
              litTest.Text += line;
      }
  
      private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
      {
          outputLines.Add(outLine.Data);
      }
  
      // Handle Exited event and display process information.
      private void ExitHandler(object sender, System.EventArgs e)
      {
          exited = true;
      }
  }
  </code></pre>