Stop Running with the Visual Studio Debugger

Tuesday, August 16, 2016

A number of people who have seen me code this year have asked me how I can make changes in an ASP.NET web application and see the changes in the browser without restarting the web application. The person asking always runs the application by starting the Visual Studio debugger.

The problem with starting the debugger is that later you’ll have to stop the debugger, and stopping the debugger also stops the default host process (IIS Express). Refreshing the browser at this point is like waiting for an echo in the emptiness of space.

No server is available to respond!



I always run web applications without the debugger. The default shortcut key for this behavior is Ctrl + F5. Now the server can stay up and running, and changes are automatically loaded and seen in the browser after a reload. I will only run with the debugger if I have to debug code.

Unfortunately, Visual Studio encourages us to run with the debugger. Not only is the shortcut key easier (just F5), running with the debugger is also featured prominently in the menus and toolbars that appear in a web project.


Do yourself a favor and use Ctrl+F5 instead!

Nuno Barreiro Wednesday, August 17, 2016
Been telling this to everyone for years now... The best way to debug is CTRL+F5 and then attach to process when needed.
skyclown Wednesday, August 17, 2016
Thak you for the insights, Captain Obvious!
gravatar Tudor Thursday, August 18, 2016
I always use the 'full' IIS instead of IIS Express, so this is less of an issue.
gravatar Dom Thursday, August 18, 2016
If it's a serious work project I am working on, I just run full IIS and have that pointing at the site. The only time I will use the debugger is if I am debugging a problem. Just add a line in your hosts file like:
gravatar Yury Schkatula Thursday, August 18, 2016
Another potential issue with "debugger approach" is caching issue. You may miss that awkward moment your website starts aggressively caching things on the client because you re-start IIS host all the time. Unlike your end-users who would get old (but not expired yet) content and need "Force refresh" the page they visited few days ago and still see it from local cache rather than latest from the server. And "+1" to @Dom comment - full IIS is a must for any production-level project.
gravatar jstemper Thursday, August 18, 2016
To make life simpler I just go into my VS options/environment/keyboard, find the Debbugger.Start node remove the F5 and change it to Ctrl-F5 and then move down the list to Debugger.StartWithoutDebugging and change that to F5. Solves the problem on my main machine and is simple enough to change on other machines I may end up using.
gravatar jstemper Thursday, August 18, 2016
On the previous comment it should be Debug.Start and Debug.StartWithoutDebugging
gravatar superzadeh Friday, August 19, 2016
You can actually use gulp-shell to start an ASP.NET website on IIS-Express and integrate this into your gulp debug workflow:
gravatar Lorenzo Tuesday, September 6, 2016
Can I debug javascript components using React,js with Visual Studio?
gravatar TweeZz Saturday, September 17, 2016
First Ctrl+F5.. Then when I need to debug [Alt+d] (pops up the Debug menu), [p] (attach to Process), [iis] (selects the iisexpress process) hit enter ==> you're in debug mode You want out? Shift+F5 It's a matter of seconds to attach / detach :)
gravatar Nag Thursday, September 22, 2016
Thanks @TweeZz - I'm going to use this all the time now! I had an academic understanding of attaching to the process, but your simple comment made it so easy to understand, and I just tried it out - works great. I'm a hobby programmer, so learning tips like this is always good.
Comments are closed.

My Pluralsight Courses

K.Scott Allen OdeToCode by K. Scott Allen
What JavaScript Developers Should Know About ECMAScript 2015
The Podcast!