How to properly stop running dotnet core web application?
Asked Answered
M

4

25

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?

Moulding answered 16/12, 2018 at 4:0 Comment(4)
how are you opening the project on visual studio? did you open a solution or did you open visual studio on the current folderAmanuensis
i generally either run with debugger or run dotnet watch run from command line outside vsAmanuensis
Double Ctrl+C worked for me in VS2019.Clothier
This answer #38906981 might be helpfullAbshire
T
1

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

Tantamount answered 10/2, 2021 at 12:28 Comment(0)
A
0

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.

Amanuensis answered 16/12, 2018 at 5:16 Comment(4)
Usually for testing I lunch apps normal way F5 or green button, but for being able to see updates on the fly I assumed that one Microsoft product would work flawlessly with another one. Looks like the best option for now is to use command line outside Visual Studio.Moulding
yes, it is supposed to. this seems to be a bug. I never really try doing this from vsAmanuensis
have you tried this solution? #40153354Amanuensis
It is not a bug you just have to press the stop button :)Pachalic
I
0

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.

Incorrect answered 3/1, 2023 at 9:0 Comment(0)
P
-3

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

Pachalic answered 5/11, 2021 at 21:19 Comment(2)
as stated in the original question, that button didn't work. I hope it got fixed finally.Moulding
yeah I was having the same issue but that button started working so I no longer had that issue sorryPachalic

© 2022 - 2024 — McMap. All rights reserved.