IIS Express Immediately shutting-down running site after stopping web application

72,438

Solution 1

I recently faced a similar situation when suddenly my IIS Express stopped right after I stopped debugging. This happened after I turned on "Enable Edit and Continue". So if you disable this you will see that IIS Express stays running even after debugging is stopped.

Right click your project > click Properties > select the 'Web' tab on the left > uncheck the Enable Edit and Continue checkbox.

Solution 2

In VS2010 and VS2012, the edit and continue option is disabled by default when creating a new web application project. In VS2013 it is turned on by default.

You can find this option on the Web tab in the web project’s properties window.

edit and continue option vs2013

With “Enable Edit and Continue” on, the VS debugger starts your web application in IIS Express. When you stop debugging, IIS Express is closed too. With this behavior, you will see the IIS Express system tray shows up during debugging and gone after debugging. This behavior is the same as in VS2012 when the Enable Edit and Continue option is turned on.

If you don’t need "Edit and Continue" functionality during development and would like IIS Express to stay after a debugging session, you can simply turn the Enable Edit and Continue option off.

If you want to use "Edit and Continue" or you are developing an Asp.net 5 site (ASP.NET 5 projects don't have an Edit and Continue checkbox in project properties) you have to use the "Detech all" command to stop debugging.

The debugger will detach from the iis process without closing it.

Clearly "Edit and Continue" feature will not work until you start debugging again.

enter image description here

Solution 3

Instead of hitting the (X) STOP button, you can use the Detach all menu item in the Debug menu. The major difference is that the stop button will terminate any process that is currently being debugged, while Detach All will disconnect the debugger from the processes, but will not terminate them.

The normal IIS worker process would also be terminated, but since it used to be running as a service, it will also automatically start up again and thus you could continue to use it without having to restart the process through |> Debug or |> Start without debugging.

Screenshot for Reference

Adding 'Edit and Continue' button to debugging toolbar.

Solution 4

It seems like since the release of Visual Studio 2015 Update 2 the accepted solution no longer works.

The easiest solution I've found so far is to start the project by selecting "Start Without Debugging" from the Debug menu.

Solution 5

This is probably best categorized as another workaround, but it works for me.

I generally start the project for the first time with the "View in Browser" context menu (or CTRL-Shift-W).

From then on, anything that requires debugging, I usually attach to the new existing iisexpress process. While mousing thru context menues would make this a non-starter, it is nearly as quick as F5 with the following keystrokes:

  • Shift-F6 to build the current project or Ctrl-Shift-B to build the entire solution (this is only required if you have made changes but I thought I should mention it since F5 already does this).
  • Ctrl-Alt-P opens the attach to process dialog

  • typing "iis" will then bring you down to the iisexpress process

  • hit enter and you're attached

If you have more than one iisexpress running, the last one started will generally appear at the top of the list. Another option is to shift-select and attach to all of them.

This has a number of advantages IMO. First and foremost, it doesn't terminate the process. Second, the browser window isn't closed when you stop debugging. It cracks me up when I see a developer repeat 7 steps to get to reproducing a bug, when all he needs to do is hit F5 in an existing browser window to just repost once the debugger is connected. Last, I have to do this already when attaching to nunit, so I get a more consistent experience.

Share:
72,438

Related videos on Youtube

Saber Amani
Author by

Saber Amani

Software Developer

Updated on August 01, 2022

Comments

  • Saber Amani
    Saber Amani almost 2 years

    I'm using visual studio 2012 in the first days when I want to stop application in IDE, application was still running on IIS Express, I could browse and work with running application, but now I can't. IIS Immediately shutting-down application if I press stop button. Since I remember I didn't make any changes in setting. How should I do that running same as first days.

    • Emanuele Greco
      Emanuele Greco over 11 years
      Try 'view in browser' instead of 'play'. Did you change default browser? IE is automatically shut down on stop, Chrome is not.
    • Saber Amani
      Saber Amani over 11 years
      No, I'm using FF, but sometimes I need to debug the application.
    • Saber Amani
      Saber Amani over 11 years
      I think this is something related to IIS Express.
    • jessehouwing
      jessehouwing over 11 years
      Instead of clicking the stop button, you can also use Detach All in the Debug menu.
    • Saber Amani
      Saber Amani over 11 years
      @jessehouwing Thanks for your reply, but what exactly Detach All is doing ?
    • jessehouwing
      jessehouwing over 11 years
      It detached the debugger from the processes being debugged, but does not kill the processes in the progress.
    • Saber Amani
      Saber Amani over 11 years
      @jessehouwing I wish I could mark this comment as answer :) :P, this is not my answer but a tricky way to go around this situation.
    • jessehouwing
      jessehouwing over 11 years
      You could upvote the comment itself. I've also transferred my comment to an answer.
  • Maxime Rouiller
    Maxime Rouiller over 10 years
    I can confirm that this fixed the issue for me.
  • nv.snow
    nv.snow over 10 years
    This Works !! Right click your project > click Properties > select the 'Web' tab on the left > uncheck the 'Enable Edit and Continue' checkbox.
  • Renzo Ciot
    Renzo Ciot over 10 years
    It Works. In Visual studio 2013 Open "Tools-> Options" , Select in the tree "Debugging->Edit and Continue" and uncheck the box "Enable Edit and Continue".
  • giammin
    giammin over 10 years
    a picture is worth a thousand words :D
  • gor
    gor over 10 years
    you can read about this feature in more details here: blogs.msdn.com/b/webdev/archive/2013/07/11/…
  • Brett Caswell
    Brett Caswell over 9 years
    this is actually closer to the real answer.. The 'EDIT AND CONTINUE' option is a feature.. Attaching and Detaching the debugging tracer to a listening process is the underline concept of discussion here, and whether clicking stop terminates that listening process or simply detaches from it.. which of course you can reattach to as well.
  • Brett Caswell
    Brett Caswell over 9 years
    this answer is not wholly correct, and is misleading people apparently.. the underline concept here is whether the stop button terminates the IIS Express Managed Process or simply detaches from it.. Theoretically, you can enable the edit and continue (EAC) feature and have the stop button detach (not terminate) by default.. @gor's article reference in his comment indicates that..
  • Brett Caswell
    Brett Caswell over 9 years
    @jcmcbeth it does indeed work for IIS Express.. I couldn't possibly see it not working... IIS Express Processes are just that, their own seperate processes.. your VS debugger is starting up the process and attaching to it.. but that Process doesn't depend on your attached debugger to run anymore than your application or webserver require a visitor/user-agent/client to run in proc
  • Joel McBeth
    Joel McBeth over 9 years
    @Brett, my comment was based on personal experience. Take it or leave it.
  • Brett Caswell
    Brett Caswell over 9 years
    @jcmcbeth, that's a weird thing to say on a Q&A site when you're talking about feature support and settings. This is not a take it or leave it scenerio; You stated that it doesn't appear to work with IIS Express. It does.
  • fhilton
    fhilton over 9 years
    I had an IIS Express error running Visual Studio 2013 via Parallels on Mac. Running VS as Administrator solved the problem.
  • Josh M.
    Josh M. over 9 years
    @jessehouwing: Yes, this is the proper way to do it unless a "do not stop underlying process when terminating a debug session" option exists. That would be ideal, really. Added a screenshot to your answer. Maybe that will help draw more attention to it, instead of the incorrect accepted answer above.
  • Josh M.
    Josh M. over 9 years
    No, this is a bad solution - see the correct solution, posted by @jessehouwing, below.
  • Tomek
    Tomek almost 9 years
    The "Enable Edit and Continue" checkbox is not present in the VS 2015 RC for ASP.NET 5 projects, so that's the way to go if you want to use IIS Express with these.
  • genuinefafa
    genuinefafa over 8 years
    this seem to be the right answer, since you are answering "how to avoid vs to shutdown IIS" cheers mate!
  • jpmc26
    jpmc26 over 8 years
    If you do this, do you start accumulating processes as you debug multiple times? When does a detached IIS Express process exit?
  • jessehouwing
    jessehouwing over 8 years
    @jpmc26, no it will reattach to iis express.
  • Krish
    Krish over 8 years
    Thanks Abhi. Did the trick "Right click your project > click Properties > select the 'Web' tab on the left > uncheck the Enable Edit and Continue checkbox."
  • Robharrisaz
    Robharrisaz about 8 years
    This is the answer to how VS 2015 Update 2 has changed IIS Behavior with the removal of Edit and Continue from the Project web tab.
  • Aron Boyette
    Aron Boyette about 8 years
    This does not work for me using Visual Studio 2015 Community. Instead I opted for the Detach All solution mentioned by @giammin (including changing Ctrl-F5 to Detach instead of Stop) and that seems to be working.
  • Chad Carisch
    Chad Carisch about 8 years
    Sounds like you're talking about VS2015.
  • nikib3ro
    nikib3ro about 8 years
    Damn, I just ran into this problem and posted question on this. Is there any known workaround to solve this - other than rebinding your shortcuts to Start without Debugging and Detach instead of Stop?
  • mattmanser
    mattmanser almost 8 years
    They say they're fixing it in the next update, in the mean time another trick you can use is to hit ctrl+F5 to start the site without debugging: connect.microsoft.com/VisualStudio/feedback/details/2562576/‌​…
  • Tomas Hesse
    Tomas Hesse over 3 years
    Thanks for "Ctrl-Alt-P opens the attach to process dialog" forgott about it