About my blog

I write about the technical and non-technical aspects of software development

How it works

Microsoft ASP.NETASP.Net
BlogEngine.NET BlogEngine.NET
Azure DevOpsAzure DevOps

Contact info

 Email
 Contact

Follow me

Prod-20240407.1

Setting up IIS Express

This is a brief post describing how I set up IIS Express on Visual Studio 2010. Using the built in V

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



                
                    
                
                
                    
                
            

Under the bindings section add



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.

 

EDIT 30 July 2016: I realise that bits of code are missing from this article.  As of now IIS Express is pretty well established in the (.NET) developer toolkit so I see no point in revising and fixing this article.  I hope it still is some use to the reader though.


You Might Also Like


Would you like to share your thoughts?

Your email address will not be published. Required fields are marked *

Comments are closed