18

How can automatically I stop the development web server when I stop debugging in Visual Studio?

Charles
  • 48,924
  • 13
  • 96
  • 136
Hannoun Yassir
  • 18,630
  • 22
  • 74
  • 109
  • why would you need to do that? its not like a WinForm Environment. In a web application you can edit code while the dev server is still running, and hit refresh and see the changes. – Darknight Aug 26 '09 at 14:36
  • i want it to stop because the application keeps working when the development server is running – Hannoun Yassir Aug 26 '09 at 14:40
  • how is that possible? unless you have some client side code that continues? – Darknight Aug 26 '09 at 15:02
  • When the application start it creates a thread that do somework and that thread keeps running as long as the development server is running – Hannoun Yassir Aug 26 '09 at 15:12
  • ok, that makes a little more sense, do you not have any stopping conditions for this thread that you spawn? – Darknight Aug 26 '09 at 15:52
  • no ! it just stops when the app stops – Hannoun Yassir Aug 26 '09 at 16:45
  • 6
    I have the opposite problem on one machine. My development server stops when pressing stop on the debug in visual studio. I only came across your posting is because I wast trying to find a solution for my particular problem. – 7wp Jan 11 '10 at 04:51
  • @7wp did you find a solution to your problem? I have the same... – Greg Oct 21 '11 at 14:47
  • @Greg nope, I have since moved on to another machine and this one does not exhibit those issues. Plus I have been using IIS a lot more for testing too. I find that any inconsistencies that occur after deployment as a result of putting the app on IIS can be discovered earlier by using IIS in the first place to do the development. – 7wp Oct 21 '11 at 17:16

3 Answers3

15

Workaround: Debugging Global.aspx.cs Application_Start() with ASP.Net Web Server within Visual Studio

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.

mishal153
  • 1,378
  • 3
  • 23
  • 37
mat3
  • 779
  • 6
  • 12
  • 1
    I had enabled Edit & Continue and it shut down Cassini when I stopped debugging. I'm running x64 - maybe that's what makes difference. @mat3 - were you running x86 or x64? – mco Nov 07 '12 at 09:50
  • I thought it was stopping a debugging session that was causing cassini to shut down. But I think it's actually editing a file that needs to be checked out of TFS which causes the project to be reloaded that's the real culprit. – Daz Mar 07 '13 at 13:52
  • The same as mco happened to me: enabling Edit and Continue does indeed stop Cassini when I stop the debugger. I am on VS2010 x64, don't know if this will apply to VS2008 (as per original question). This helps a lot with Entity Framework based apps, that keep a connection open to the DBMS, when you need (at early stages of the development) to drop the whole database quite frequently. – Alex Mazzariol Nov 21 '13 at 09:29
4

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).

Community
  • 1
  • 1
Justin
  • 80,106
  • 47
  • 208
  • 350
0

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.

Community
  • 1
  • 1
Sebastian
  • 3,446
  • 17
  • 27