I have an ASP.Net application that performs some database initialization during Application_Start in Global.asax. I'm using IIS Express to debug the application.
I find that if I stop debugging, clear the database, and restart again, the Application_Start code does not get called and my database is not initialized properly, so my application fails. This is because the IIS Express instance is still running after debugging stops. Rather than restarting it, Visual Studio appears to be attaching to the existing process.
Is there a way to change this behavior such that starting a new debugging session always restarts the application process in IIS Express (or resets the application pool in regular IIS)?
Alternatively, is there a way to force IIS Express to shut down when the debugging session ends?
I did find that if I check "Enable Edit and Continue" from the Web dialog in the project settings, that it has the side effect of stopping IIS Express when debugging ends. But I'm not sure I want to introduce the side-effects of Edit and Continue just for the purposes of stopping IIS Express. Surely there's a better way?
Not sure if it matters, but this is VS2012.
See Question&Answers more detail:os