Setting up IIS Express

This is a brief post describing how I set up IIS Express on Visual Studio 2010. Using the built in Visual Studio Development Server (a.k.a Cassini) is great in many cases but it has a few limitations, for me the most significant are
• No SSL support
• Can only run localhost – so nobody can browse to your development site whilst you are working – assuming you want to show them of course.

Using IIS Express gives developers almost the full functionality of IIS 7.5 which should cover most development scenarios. I believe a notable exception is some aspects of Sharepoint development.

1. Installation

Okay so the first step is to get and install IIS Express. You can download this from the web – it is quite a small download (around 10MB) and a fast install. You can also, if you’ve got Visual Studio 2010 SP1, use the ‘Install Web Components’ feature to get and install it.

EDIT 21 Mar: Thanks to Sebastien for pointing out that the config files in the user profile are not created until the first attempt to use IIS Express from Visual Studio. Do step 4 and then return to step 2.

2. Configuration

Once it is installed, IIS Express is configured via a file called applicationhost.config which is in C:\Users\\Documents\IISExpress\config. What this means is that every user can have their own IIS Express settings.

By default, the configuration is set to only browse localhost with anonymous authentication. This is easily fixed:

Navigate the XML tree as follows:

Configuration -> system.applicationHost -> sites

This section allows configuration of the sites hosted by IIS Express. By default you’ll have

  1. <site name="MyDevSite" id="2">
  2.                 <application path="/" applicationPool="Clr4IntegratedAppPool">
  3.                     <virtualDirectory path="/" physicalPath="C:\SVN\dev_main\WebSites\MyDevSite" />
  4.                 </application>
  5.                 <bindings>
  6.                     <binding protocol="http" bindingInformation="*:54632:localhost" />
  7.                 </bindings>
  8.             </site>

Under the bindings section add

  1. <binding protocol="http" bindingInformation="*:54632:MyPCName" />

Now, we have to change the authentication to allow Windows authentication.

Navigate the XML as follows
Configuration -> system.applicationHost -> system.webServer -> security -> authentication -> windowsAuthentication.

Set the windowsAuthentication “enabled” parameter to “true”.

3. Security

Now if you try to navigate from your browser to http://MyPCName:54632 you’ll be surprised to find you get a 401 error. That is because as an extra security measure, you have to set up url access to your PC as an administrator.

Run the following at an elevated command prompt (Windows 7)
netsh http add urlacl url=http://MyPCName:54632/ user=everyone

For others to access the site there may still be additional matter of firewalls. The firewall on the PC (or router) will need to be configured to allow traffic to your chosen port(s).

You can subsequently stop access to your site using
netsh http delete urlacl url=http://MyPCName:54632/

4. Use from Visual Studio

Finally, how to use IIS Express instead of Cassini from Visual Studio? Easy: Right click on the project and the context menu will have an item ‘Use IIS Express…’ (just under the ‘Set as Startup Project’ item). Choose this and click Yes and then OK on the dialog boxes that follow.

If you change your mind later and want to go back to Cassini, the context menu item will be replaced by a ‘Use Visual Studio Development Server’ item which you can click to change things back.

Now when you run the site from Visual Studio, the IIS Express is started and the site launches as you would expect. The difference is in the system tray. Instead of the familiar Cassini icon(s) will be a single IIS Express icon. Right click on this for context menus (and a very simple Windows UI) to carry out simple management (e.g. stop/start of sites).

As this is quite a light-weight feature, all the serious configuration needs to happen in the configuration file mentioned above.

Hope this helps somebody.

3 Comments on “Setting up IIS Express”

  1. #1 Sebastien
    on Mar 18th, 2011 at 20:54 pm

    Super! That will be helpful for rest services development, as Visual Studio Development Server does not handle rest parameters very well.


  2. #2 Sebastien
    on Mar 18th, 2011 at 21:47 pm

    Note that you should do step 4, before you do step 2. Otherwise, the IISExpress folder and the config file do not exist yet, and you cannot edit them.

    I tried reinstalling twice, because I could not find the config file.

    Thanks! :-)

  3. #3 Daishik
    on Mar 20th, 2011 at 16:15 pm

    Interesting that you had this issue, and it’s probable that I didn’t notice the issue because when I installed I must have gone straight to VS and set it to use IIS Express without even thinking about it.

    I must have subsequently gone to the config file to do the rest of the stuff.

    Thanks for reading and thanks for the tip!

Powered by WordPress

Website design adapted from WordPress theme PrimePress

Warning: is_executable() []: open_basedir restriction in effect. File(/usr/local/bin/curl) is not within the allowed path(s): (D:\inetpub\vhosts\\;C:\Windows\Temp\) in D:\inetpub\vhosts\\httpdocs\wordpress\wp-includes\class-snoopy.php on line 216