Visual Studio Projects on a Windows 2003 Server Running SharePoint (MOSS)

If you try to create a new .NET Web project (ASP .NET Web Application or ASP .NET Web Service) on a server running MOSS (or, presumably, SharePoint v2), you will get the error:

‘Unable to create Web Project ‘WebApplication1’. The file ‘c:\inetpub\wwwroot\WebApplication1’ does not correspond to the URL ‘http://localhost/WebApplication1’ where WebApplication1 is the name of your new project.

Though the message certainly doesn’t indicate it, this is because Visual Studio wants to use port 80 for the Web project. However, by default SharePoint runs on port 80, and it has "taken control".

The simple solution is to create a new Web Site using IIS:

  • Open IIS Manager
  • Expand the Local Computer node
  • Right click on Web Sites and choose New>Web Site…
  • Go through the wizard to create the new Web Site: Name your site, choose an unused port (something like 8111), choose the path, (usually something like C:\Inetpub\wwwroot\VS Site), set the permissions, and you’re done.

Now, go back to Visual Studio, and choose File>New>Project>[the template that you want to use] and specify the port of the Web site you just created, like so: http://localhost:8111/WebApplication1.

This should work for any version of Visual Studio.

Have a thought or opinion?