September 23, 2015
Visual Studio provides a great development ecosystem for .Net developers (and pushing into Node and other platforms). One of it’s best features is the ease with which one can start a new project. File -> New -> Web Project -> F5, and you have a decent looking template website up and running.
The default setup is great for POCs and small projects, but any serious project will require customization. One of the first things I do with any larger project is switch from IIS Express to IIS. Any project involving multiple (human) resources should be using IIS instead of IIS Express in my opinion. What you want to do is make sure your local environment resembles your test and production environments as closely as possible. I will later mention some of the downsides of using IIS instead of IIS Express.
Important: you need admin access to your machine to complete the following steps.
To install IIS, go to your Run Command window (Win + R), type optionalfeatures, and hit Enter. In the dialog that pops up next, select “Internet Information Services”, the default settings are ok for now. Click Ok and wait for the configuration to complete. When done, run the inetmgr again to get to the IIS Manager window.
In the IIS Manager window, righ-click “Sites” and select “Add Website”, then populate the Site Name, Physical Path, and Host Name (see image below for an example). Click OK and you are set.
C:\Windows\System32\drivers\etcOpen the "hosts" file with a text editor, just make sure to open the text editor in "Administration Mode" or you will not be able to save. Once you have the file open, go to the bottom and add something similar to the following:
And that will do it, you are now set to access a website or application hosted at c:devmyapp through http://dev.mydomain.com.
The simple step to avoid this skip is to run the application, after the debugger has been attached, go and modify the web.config (it could just be adding or removing a space), save, and refresh the page on the browser. Editing the web.config will cause the application pool to restart, but the debugger will stay attached. Now you can get to your breakpoint.
Final word of caution, modifying the hosts file is dangerous, the file is a frequent target of viruses and malicious software. Follow these instructions at your own risk.
Written by Visar Gashi