title: What is the proper way to stop/kill a .net core web app process after launching a process to display the browser
body: <p>When creating a .NET Core Web app C# and debugging you can opt to Launch the browser when Running the app.  The console launches and then the url launches in your preferred browser.  Once you close the browser tab opened by the debug session, the app process it stop and is no longer running on the machine.</p>
  <p>When I published the app, the page does not launch automatically so I am starting a new Process to do so.  I've added an event handler to the process before starting it but the since the app didn't launch the process it doesn't receive any notification when the tab has been closed.</p>
  <p>What is the proper way to go about launching your .NET Core web app and/or handle communicating between the two?</p>
  <p>I even tried adding a Close button but JS won't allow me to close the window as I haven't opened it.</p>
  <p>I'm creating my Process as follows:</p>
  <pre><code>var p = Process.Start(&quot;cmd&quot;, &quot;/C start http://localhost:5000&quot;);
  </code></pre>
  <p>I've tried</p>
  <pre><code>p.WaitForExit();
  p.EventHandler += newHandler;
  </code></pre>
  <p>and I also tried using ProcessStartInfo but the only thing that is working right now is if I set a Timer and then kill the process when the timer is activated but this doesn't seem too clean.</p>
  <p>Any advice is appreciated!</p>