Though Visual Studio 2010 SP1 will have out-of-the-box support for developing and debugging web applications against IIS Express 7.5, you can still use plain VS 2010 against IIS Express with few manual steps. Here is how:

  1. Install IIS Express (IISE) 7.5 RTM (download it from http://goo.gl/nQ9Cu).
  2. Assuming IISE was installed at the default location – C:\Program Files (x86)\IIS Express, open up a command prompt window and navigate to that folder.
  3. Run iisexpress.exe. This would create the default configuration and other files underneath your Documents folder C:\Users\user_name\Documents\IISExpress\config) and startup IIS Express listening at a port configured by default:

IIS Express Console

  1. Press Q to quit IIS Express and open the ‘just created’ application host configuration file: C:\Users\user_name\Documents\IISExpress\config\applicationhost.config in Notepad (or your favorite!).
  2. Go to <configuration>/<system.applicatioHost>/<sites> section and make a replica of the existing WebSite1 site element below (or above) it – now the <sites> section will have two child <site> elements – the default WebSite1 and the copy. Make changes suggested from here to either the copy or the default WebSite1.

Let’s see how to hook up an existing web application with IIS Express using Visual Studio 2010 (without SP1); I am using BlogEngine.NET for this demo. The solution may sound hacky, but, there is no other way around to accomplish this as far as I know but leave a comment if you know any better ways.

Open your web application in VS 2010. Next, make a note of the port number that the web application uses if it is backed by the VS web server: select the web application in Solution Explorer and press F4. On the Properties dialog, you will see the port number as shown below:

Website Properties

 

The Properties dialog will not have the "Developer Web Server" section if you use the default IIS and hence you can use any port and change all dependencies wherever referenced. For instance, you need to update service reference URLs in WCF clients if the web app in question is a WCF service.

Now, switch back to applicationhost.config and make the following changes:

  • Give any value you like for the name attribute of the <site> element but a unique number (within <sites>) for the id attribute.
  • If your web application targets .NET 4.0, then add attribute applicationPool to the <application> element and assign Clr4IntegratedAppPool to it, otherwise Clr2IntegratedAppPool. Both the app pools are already defined in the host configuration file. This step is optional and required only if the application doesn’t work as intended
  • For the root virtual directory, set physicalPath attribute value to the absolute path of your website root and path to be root (/). The VS web server by default runs your web app under a virtual path but it needn’t be so with default IIS or IISE.
    • If your web application uses additional virtual directories, you should add them as well as the children of <application> element.
  • For the <binding> element, use localhost as the host name, but for the port, use the port number noted above.
  • Save the configuration file and please remember that I have not changed anything other than adding a new site and configuring it based on its existing configuration. A sample <sites> section with a new site configuration is shown below:

Sample applicationhost.config

  • Now, run "iisexpress /siteid:2" (or any switch that identifies the new site) at the command prompt and if everything went correctly, you should see an output similar to the one below (root site URL highlighted, which IISE picked up from the host configuration file):

IIS Express Instance Running

  • The last step is to attach Visual Studio 2010 to the running iisexpress.exe process: select menu Debug | Attach to Process… and choose iisexpress.exe:

Attach VS 2010 to IIS Express (click to expand)
 
At this point you should be able to open the root website URL in a browser and hit any breakpoints you may have.

VS 2010 with IIS Express in Debug Mode(click to expand)

Site in action…

VS 2010 with IIS Express in Action(click to expand)

That’s it!

If your web application uses, the default IIS, then things are even easier: all you have to do is pick up any port that doesn’t conflict with services running already and start IISE.

I know things may not be as straight forward as what I have shown, depending on how your web applications are structured in the overall solution, but I hope you get the idea (or you may as well wait for VS 2010 SP1 RTM or use SP1 beta!).