How can automatically I stop the development web server when I stop debugging in Visual Studio?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Enabling “Edit & Continue” on the web server project worked for me. It doesnt shutdown cassini when you stop debugging, but it does restart cassini when you start debugging.
Method 2
There is no way to get the Asp.Net development service to automatically stop when you hit the “stop debugging” button, as all that does is detach the debugger. You could however explicitly kill the process yourself (which would in turn cause VS to stop debugging).
This question shows how you might do this in a Macro:
Automatically stop/restart ASP.NET Development Server on Build
Alternatively take a look at mat3’s answer on how you can force the development server to restart every time you start debugging (although it will still remain running after you have finished your debugging session until you next run your probject).
Method 3
Another trick is to update web.config timestamp on post-build event. You may find detailed instructions how to do that in my answer to the Can Visual Studio restart IIS Express on new debugging session? question.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0