Opening .NET 2.0 Web Application Projects in Visual Studio 2008

So I’ve downloaded & installed Visual Studio 2008. First impressions: nice. It seems faster than 2005, but that may just because I haven’t installed ReSharper yet :). The multi-targeting feature that allows you to specify which version of the .NET framework to compile the project as is awesome. It makes migration so much easier. I’ve now been able to migrate our whole web solution to Visual Studio 2008 but keep the framework version at 2.0. We’ll upgrade to 3.5 later.

Very glad Microsoft decided to keep Web Application Projects built in to 2008, makes it all really simple. Everything ran fine except for one little gotcha with the web project itself. It’s not a big deal, but it was really annoying and the error messages were not overly helpful. It’s basically around Visual Studio trying to create the required virtual directory for the website in IIS. The error I was getting was:

Creation of the virtual directory http://dev.drive.com.au failed with the error: Could not find the server ‘http://dev.drive.com.au’ on the local machine. Creating a virtual directory is only supported on the local IIS server

See below for steps to reproduce & how to resolve this:

I opened up our web solution, which is using a web application project & it started the upgrade wizard. All the class library projects upgraded fine, but there was a problem with the actual web application project itself.

First I got this message:
The local IIS URL http://dev.drive.com.au specified for Web project DriveWeb has not been configured. In order to open this project the virtual directory needs to be configured. Would you like to create the virtual directory now?
And when I clicked "Yes" I got this error:

Creation of the virtual directory http://dev.drive.com.au failed with the error: Could not find the server 'http://dev.drive.com.au' on the local machine. Creating a virtual directory is only supported on the local IIS server

I figured this was because I’m running Windows XP and can only have one site in IIS. I’ve already got a site setup for our dev build pointing at another folder (I’d checked out a clean copy of our site to do this migration on). So I added dev.drive.com.au as a host header on this, but then it gave the error

Creation of the virtual directory http://dev.drive.com.au failed with the error: The URL ‘http://dev.drive.com.au’ is already mapped to a different folder location.

This one was basically because the site in IIS was pointing at a different folder. So there’s two options at this point. The simplest is to just change IIS to point at the same folder that Visual Studio 2008 is, but if you don’t want to do that you can just turn off the IIS mapping in the project file.

Open up the csproj file (right click on the project in the solution explorer) and I find this section at the bottom of the file:

  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>False</AutoAssignPort>
          <DevelopmentServerPort>1866</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>http://dev.drive.com.au</IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>

Basically what this is telling Visual Studio to do is create a Virtual Directory on the local IIS, which it was unable to do. To solve this problem just change the value of UseIIS from True to False.

Then save the .csproj file and reload it. Sorted. I’m really not sure why the interface doesn’t ask you whether to turn off IIS when the error occurs, that would seem to be the most logical thing to do, but oh well.

Now that’s been sorted, everything’s working fine. Built the solution & it’s loading up exactly the same as it was under Visual Studio 2005. On to 3.5…

12 thoughts on “Opening .NET 2.0 Web Application Projects in Visual Studio 2008

  1. Doesn’t this solution cause your properties -> web settings to revert to “Use Visual Studio Development Server”, and thus you can no longer debug using IIS?

  2. Doesn’t this solution cause your properties -> web settings to revert to “Use Visual Studio Development Server”, and thus you can no longer debug using IIS?

  3. This was a great solution to an annoying issue. Your site was the only one I could google and get a straightforward solution!

  4. This was a great solution to an annoying issue. Your site was the only one I could google and get a straightforward solution!

  5. I had terrible problems with this issue. If you need to run with IIS instead of the Development Server, check your IIS settings for the website. In IIS, on the “Bindings” screen make sure that the “host name” field is set to blank. If the host name value set to anything else (including “localhost”) Visual Studio 2008 will have problems loading the project. Host name must be blank in IIS.

  6. Thanks – this was the problem I was having – in fact this fixes the supposed “work-around” whereby you instruct visual studio to NOT use IIS. For a while I was doing this, and using 'Custom Server URL' to point to my application on my local server. This is what should be done ^Thanks again

  7. I have my project developed in VS2003 and wanted to upgrade to VS2008. When i run the migration tool, it runs successfully without taking any time but under solution the project is not loaded. I’m not sure what i’m doing wrong. Can anyone tell me steps to migrate a VS2003 web application to VS2008?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>