>
 





According to Microsoft, Internet Information Services 7.0, or IIS7, is the most advanced, secure and customizable platform for developing and reliably hosting Web applications and services. With IIS7, you can create sites, applications and virtual directories to serve requests. In order to serve requests and share information with users over the Internet, an intranet, or an extranet, you need to create a set of configuration that describes how the server listens for requests, and how these requests are handled. 

In this article, I explain the important differences between IIS6 and IIS7 in the way sites, applications and virtual directories work and how to create and configure them in IIS7.

In IIS6, the concepts virtual directory and application are conceptually different. However, an application cannot be physically separated from a virtual directory. Also in IIS6, an application is less important than the technology that extends the web server functionality, such as ASP and ASP.NET. These technologies provide additional features and IIS isolates applications in a way that would prevent applications in one application pool to affect applications that are in another application pool.

On the other hand, in IIS7, virtual directory and application are completely separate objects; they exist in a hierarchical relationship in the configuration schema. A site contains one or more applications; an application contains one or more virtual directories; and a virtual directory maps to a physical location.

Site

A site is a logical container that specifies how http requests are received and processed for applications and virtual directories. It also defines one or more unique bindings that determine how the site listens for incoming http requests.

Bindings

A binding includes two attributes which have key importance for communication: the binding protocol and the binding information. The binding protocol defines the protocol between the server and client. For example, the binding protocol of a web site may be HTTP or HTTPS. The binding information contains the information that is used to access the site. Usually, the binding information is the combination of an IP address, a port number and an optional host header. Only bindings determine which site the request is routed to.

You may host many sites on a single server that listen on:


The following configuration settings also belong to the site beside applications and bindings:


An application is a logical container of a site’s functionality. 

Basic steps to serve a website using IIS7 contain:

  1. Creating a site
  2. Creating an application
  3. Creating a virtual directory
  4. Creating an application pool


Although IIS7 comes with “Default Web Site” serving on Port 80 for all host headers and single application located in %systemdrive%\inetpub\wwwroot, we may have multiple websites serving over different domain names/ports, or we may want to place a part of a website into a different application pool, or we may have different ASP.NET applications, or we may want to serve a part of a website from a different physical location by creating a different virtual directory.

Let’s start with creating a new website that will be served over port 81 of the localhost. 

This post will show how to do add new website from the Internet Information Services Manager, but you can do these by using the IIS7’s AppCmd.Exe command line tool, located in %windir%\system32\inetsrv. 

To start IIS Manager from the Run dialog box

  1. On the Start menu, click Run.
  2. In the Open box, type inetmgr and then click OK.


To start IIS Manager from the Administrative Services console

  1. In the Control Panel window, click Administrative Tools.
  2. In the Administrative Tools window, click Internet Information Services (IIS) Manager.

Internet Information Services(IIS) Manager
Internet Information Services(IIS) Manager


To create a new website using IIS Manager, click on the Web Sites under Connections and then click on the Add Web Site link under Actions.

Adding a new website using IIS Manager
Adding a new website using IIS Manager


In the Add Web Site window:

  1. Type your web site name.
  2. Select Physical path of your web site.
  3. Type 81 as your port number.
  4. Click OK.

Settings properties of the website
Settings properties of the website


This creates a new website named “bloggingdeveloper”, with id = 2, and creates a single HTTP binding configured to listen on all interfaces, port 81, without a host-header restriction. At this point, you can immediately access the site with http://localhost:81/.

You might have come across to the following “HTTP Error 500.19 - Internal Server Error” while working on Windows Vista. Actually Microsoft has tightened the security on Windows Vista and most of the time it is annoying when it asks your permission.

HTTP Error 500.19 - Internal Server Error
HTTP Error 500.19 - Internal Server Error


To resolve this problem:

Compile the project and place the deployable files under C:\Inetpub\wwwroot\. Make sure that the physical path of the respective Application (e.g. BloggingDeveloper in above error case) under IIS now points to new path.

OR

Browse your application root folder and add group IIS_IUSRs.

Resolving HTTP Error 500.19 - Internal Server Error
Resolving HTTP Error 500.19 - Internal Server Error


After granting permission to the application root folder, you might come across another problem: Server Error in Application "bloggingdeveloper" - HTTP Error 500.0 - Internal Server Error.

HTTP Error 500.0 - Internal Server Error
HTTP Error 500.0 - Internal Server Error


Follow the directions shown on the error message to resolve the problem:

You can migrate the application configuration, including the contents of the configuration section, by using the following from a command line window (the window must be running as Administrator):

%systemroot%\system32\inetsrv\APPCMD.EXE migrate config "bloggingdeveloper/"

1) Migrate the application to work with the Integrated .NET mode (PREFERRED).

You can migrate the application configuration, including the contents of the configuration section, by using the following from a command line window (the window must be running as Administrator):

%systemroot%\system32\inetsrv\APPCMD.EXE migrate config "bloggingdeveloper/"

After you migrate your application, it will run in both Classic and Integrated .NET modes, as well as on downlevel platforms.

2) Move this application to an application pool using the Classic .NET mode.

You can move the application to the default application pool using the Classic .NET mode by running the following from an command line window (the window must be running as Administrator):

%systemroot%\system32\inetsrv\APPCMD.EXE set app "bloggingdeveloper/" /applicationPool:"Classic .NET AppPool"

Alternatively, you can use any other application pool on your system that is running in the Classic .NET mode. You can also use the IIS Administration tool to move this application to another application pool.

After Migrating the application to work with the Integrated .NET mode, you might come across another problem: Server Error in Application "bloggingdeveloper" - HTTP Error 401.3 – Unauthorized

HTTP Error 401.3 – Unauthorized
HTTP Error 401.3 – Unauthorized


Resolving HTTP Error 401.3 – Unauthorized Error
Resolving HTTP Error 401.3 – Unauthorized Error


Click on Authentication and click edit after choosing Anonymous Authentication. In the opening window select Application Pool identity and click OK.

Resolving HTTP Error 401.3 – Unauthorized Error - Application Pool Identity
Resolving HTTP Error 401.3 – Unauthorized Error - Application Pool Identity


Now we are ready to browse the website.

Serving bloggingdeveloper in localhost over port 81
Serving bloggingdeveloper in localhost over port 81


If you don’t want to struggle with the above errors, just place the deployable files under C:\Inetpub\wwwroot\.

UPDATE Another step by step tutorial is available about accessing a local site via name (e.g. http://bloggingdeveloper/) using the Hosts file instead of http://localhost:81/.

Accessing Local IIS Web Sites via Name using the Hosts File

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 4.5 by 4 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Comments

August 29. 2007 18:43

Nice post Smile You can also check out the original post at  mvolo.com/.../...C00_-and-virtual-directories.aspx for more information and steps for creating web sites from the command line.

Thanks,

Mike

Mike Volodarsky | Reply

August 29. 2007 21:21

Mike,

Thank you very much for your comment. I read your post. I think users using the command line tool, do not struggle with the errors I mentioned above. Am I right?

Cheers,

Blogging Developer | Reply

January 28. 2009 12:49

I think most people would want to make their sites available
on port 80, not 81.  If it is on 81, then everyone who wants to browse to the site will have to enter port 81.  I think this would cause mass confusion.

Harold Naparst | Reply

February 18. 2009 14:42

Can I Use Sites["Default Web Site"] in place of Sites[0];

Ankush Bindlish | Reply

October 22. 2009 18:10

Social comments and analytics for this post

This post was mentioned on Twitter by bloggingdev: Creating IIS7 sites, applications, and virtual directories using Internet Information Services Manager - http://su.pr/8gbELP

uberVU - social comments | Reply

Add comment




(Will not be displayed!)