Configure your development environment with IIS

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.

Configure IIS

The first thing you need to set up is IIS itself. It must be installed, and it is not by most default Windows installations. The quickest way to get to IIS is by going to your Run Command window (Win + R), typing inetmgr, and hitting Enter. If you don't have IIS installed, you will know now.

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.

Configure Host

Simply creating the site is not enough, you need to also configure your host file to trick your system into redirecting you to your site when you type in the "dev" domain. To do that, go to
Open 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

Summary and Caution

With the above configuration, you can now:
  • Access the site using the same path as your dev environment (assuming you have a dev environment that you share with other developers)
  • Access the site without Visual Studio up and running. You can modify static files, as well as certain auto-compile Asp.Net files (e.g. MVC Views) without Visual Studio.
  • Access the updated site after compiling without being in Debug mode, even when Visual Studio is running
  • Have the same configuration for your dev environment for each developer
In addition to requiring admin access to have this configuration (and the risk of editing the hosts file), to date I have only encountered one challenge with this configuration. When you run your web application through IIS, the Asp.Net Process debugger attaches later in the pipeline than it would through IIS Express. What this means is that if you put breakpoints into code such as your Global.asax.cs, or Startup.cs (for Owin), the debugger will skip it.

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