Login :: Register
General Topics
An error has occurred.
Error: Sponsored By is currently unavailable.

2005 IIS MVPs
Other IIS Sites
  Visual Studio.NET and IIS 6 - Unable to create Web Application 

Visual Studio.NET and IIS 6 - Unable to create Web Application

Visual Studio.NET - Unable to create a new web project

Trying to create a new Visual Studio.NET web application on IIS 6 can fail with the following error message:

Unable to create web project 'X'. The file path 'X' does not correspond to the URL 'http://Localhost/X'.

The two need to map to the same server location.

HTTP Error 404: Not Found

Visual Studio.NET and IIS 6 has a limitation that can be very tricky to find unless you know exactly what is going on. By default on IIS 6 any file that does not have an associated MIME type is blocked and will return a 404 error status meaning the document was not found, as can be seen below from a snippet of a web server log file.

#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2002-12-25 19:47:45
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status
2002-12-25 19:47:45 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 - 127.0.0.1 MSFrontPage/4.0 200 5 0
2002-12-25 19:47:45 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 - 127.0.0.1 MSFrontPage/4.0 401 1 0
2002-12-25 19:47:45 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 IISFAQ\Administrator 127.0.0.1 MSFrontPage/4.0 200 5 0
2002-12-25 19:47:45 127.0.0.1 GET /IISFAQ/~~212877160129535310.tmp - 80 - 127.0.0.1 Microsoft-Visual-Studio.NET/7.00.9466 404 3 50

The above log entries are the requests to the IIS 6 Web Server for a new Visual Studio.NET web application to be created. The request was made with Visual Studio.NET and IIS 6 on the same computer.

The last request is a request for a .TMP file that Visual Studio.NET creates. The reason the temporary file is created is apparently to ensure that the file path and the web server root point to the same location.

Steps to reproduce on IIS 6

You create a new Visual Studio.NET web application at http://localhost/IISFAQ

Visual Studio.NET then determines the physical path of the root directory of the Localhost web site.

By default this will point to c:\inetpub\wwwroot.

Visual Studio.NET then creates a temporary file in c:\inetpub\wwwroot and attempts to read the file by an HTTP GET request. If the file can not be read then it assumes that the path is incorrect and will provide you will the following dialog.

Clicking the Help button on the dialog will display the following:

HTTP Error 404: Unable to create Web project

Unable to create Web project 'IISFAQ'. The file path 'c:\inetpub\wwwroot\IISFAQ' does not correspond to the URL 'http//localhost/'. The two need to map to the same server location.

For more information, see Unable to Locate Object on Web Server.

Unable to Locate Object on Web Server

Visual Studio .NET is unable to locate an item on your Web server because the item has either been moved or renamed. To map a connection to the object, click the ellipses () button in the error message and browse to the object's location on your Web server. Selecting the item will repair the address to the object within your application.

Normally these answers will point you in the right direction - that is:

The web site Root Directory must point to the same location as the file path.

If your web site Root directory is d:\inetpub\websites then you must enter d:\inetpub\websites into the location field of the dialog (appending the name of the new site as well).

IIS 6 is different than IIS 5

With IIS 6 you may find that the web site root directory is in fact c:\inetpub\wwwroot and you can not see anything wrong but you still always get the Web Access Failed dialog.

In IIS 6 any file type that does not have a MIME type associated with it is denied access generating a 404 status. This is why the log entries above show you that the request failed.

Although Visual Studio.NET could create the temp file in the c:\inetpub\wwwroot directory it could not read it back when requested using a HTTP GET statement. When this occurs Visual Studio.NET shows the Web Access Failed dialog assuming that the file path and the web path to not match.

To fix this problem you simply need to create a new MIME type for .TMP

Open the Internet Information Services (IIS) Manager from Administrative Tools and select the Web Site.

Select the HTTP Headers tab and then click on the Mime Types... button

By default there are no custom MIME types registered, click on the New... button.

Enter the following into the Mime Type dialog

Extension: .TMP

Mime Type: temp/temp

Click OK to save the changes and you should see the following dialog.

Click OK to close the MIME types dialog, and then click OK to close the web site properties dialog.

After this change return to Visual Studio.NET and proceed to create the new web site again; Visual Studio.NET will create the new web site without problems.

Looking at the log files after the change we see the request now succeeded.

#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2002-12-25 21:01:38
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status
2002-12-25 21:01:38 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 - 127.0.0.1 MSFrontPage/4.0 200 5 0
2002-12-25 21:01:38 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 - 127.0.0.1 MSFrontPage/4.0 401 1 0
2002-12-25 21:01:38 127.0.0.1 POST /IISFAQ/_vti_bin/_vti_aut/author.dll - 80 IISFAQ\Administrator 127.0.0.1 MSFrontPage/4.0 200 5 0
2002-12-25 21:01:38 127.0.0.1 GET /IISFAQ/~~-78625949529535320.tmp - 80 - 127.0.0.1 Microsoft-Visual-Studio.NET/7.00.9466 200 0 0
2002-12-25 21:01:38 127.0.0.1 GET /IISFAQ - 80 - 127.0.0.1 Microsoft-Visual-Studio.NET/7.00.9466 301 0 0
2002-12-25 21:01:38 127.0.0.1 GET /IISFAQ/ - 80 - 127.0.0.1 Microsoft-Visual-Studio.NET/7.00.9466 403 14 5

 This site and its contents are Copyright 1999-2004 by IISFAQ Microsoft Corporation in no way endorses or is affiliated with IISFAQ