Roman Svitukha
Roman Svitukha

Reputation: 1402

How to properly stop running dotnet core web application?

In Visual Studio 2017 and 2019 on Windows, I run dotnet watch run in the Package Manager Console. It launched kestrel for a dotnet core app, automatically disabled text edit in the console, and displayed a 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 launch the web app in Visual Studio because it is already running. I couldn't find a command like dotnet stop only Ctrl+C which doesn't work in this case. I used Process Hacker to kill the dotnet.exe process but that doesn't seem right. What would be the best way to kill the running process?

Upvotes: 25

Views: 46859

Answers (4)

sohail naseer
sohail naseer

Reputation: 71

when the service is already running just again apply build command "dotnet build" and then again run command apply like "dotnet run" services will be up again then you just have to press Ctrl+c in the terminal to shutdown running services.

Upvotes: 0

AlThePal78
AlThePal78

Reputation: 1122

There is a red button next to the clear button in that section next to the project name. I just found it LOL I will show you a picture follow the yellow circle. I was trying ctrl+c too LOLenter image description here

Upvotes: -3

DarioDS
DarioDS

Reputation: 15


run your project:

dotnet run > Examplelog.log &

$ dotnet run > Examplelog.log &

[1] 162


end your project:

kill 162

$ kill 162

[1]+ Exit 127 dotnet run > Examplelog.log


So with kill[id] you can end your process.

you not need a second console and can use your console for other inputs (take note that all outputs will be stored inside the Examplelog.log-File you have to check)^^lg

Upvotes: 1

Neville Nazerane
Neville Nazerane

Reputation: 7039

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.

Upvotes: 0

Related Questions