Here’s a gotcha! I discovered while working on an ASP.NET MVC 5 solution in VS 2015. While refactoring the code, I needed to debug some code in the Global.asax.cs and thus changed the project properties to run using IIS Express instead of local IIS.
[If you’re wondering why IIS Express for debugging the startup code, check out this excellent post from Rick Strahl that goes over various ways you can debug initialization code HERE]
Now, every time I tried running with a debugger attached (F5), I got hit by a 500.19 error code that basically seemed to suggest that by web.config is fried. At first, I tried commenting various sections in web.config to ensure I haven’t messed up any config but couldn’t spot anything that would cause the breakage.
What do programmers do when stuck (and when all attempts to restore sanity fail)? Well, no prizes for guessing, Google for a stackoverflow thread that (fingers crossed) has a solution. Luckily, I didn’t have to strain my fingers much as a gentleman had graciously shared this on StackOverflow
The Solution: Look at thy hidden folders
It turns out, with VS 2015, the visual studio team listened to many developers like Mr. Balassy and added the .vs folder to hold (almost) all of the per-user settings files – the likes of user options (.suo) et al. One of these is the applicationHost.config to control machine level IIS Express settings for the current solution. This file resides at the following place: your solution root (the place where .sln file lives) –> .vs –> config –> applicationhost.config. As visual studio can recreate this file and the entire .vs folder again, the straightforward (and easy ;-)) solution is to
- Close the solution
- Delete the .vs folder
- Reopen the solution again and in the web project settings, re-configure to debug with IIS express.
Unless you’re having a really bad dream, you should have lift-off at this stage.