How to properly stop running dotnet core web application?

Roman Svitukha picture Roman Svitukha · Dec 16, 2018 · Viewed 13.6k times · Source

In Visual Studio 2017 and 2019 on windows I run dotnet watch run in the Package Manager Console. It lunched kestrel for dotnet core app, automatically disabled text edit in the console and displayed red button to stop command execution, but the button doesn't do anything. Also the message is being displayed to use Ctrl+C but it doesn't work either.

Now listening on: http://localhost:20436 Application started. Press Ctrl+C to shut down.

Now there is an error when I try to lunch the web app in Visual Studio because it is already running. I couldn't find command like dotnet stop only Ctrl+C which doesn't work in this case. I used Process Hacker to kill dotnet.exe process but that doesn't seem right. What would be the best way to kill the running process?

Answer

Neville Nazerane picture Neville Nazerane · Dec 16, 2018

Since this stop option doesn't work it is clearly a bug. If I need to run dotnet watch run I generally just open command line on my current folder outside VS and run it from there. Since dotnet watch run has nothing to do with visual studio (no debugging) it makes sense. Alternatively, you can use the green button to run within visual studio with debugger. However, this would mean you can't edit the code while testing.