I’ve been using IIS 10 regularly over the last 2 years now and one thing that’s always confused me was the differences between sites, applications, and virtual directories and what they’re used for.
After doing some research on these components, I found that the easiest way to understand them from a high-level, is to think of them all as sort of a hierarchy of containers for each other. A site contains one or more applications, an application contains one or more virtual directories, and a virtual directory maps directly to a folder location on the disk.
With that said, a site is a container which contains applications and virtual directories. Sites can have multiple applications and directories. They can be setup and accessed through one or more unique bindings, which typically consists of a communication protocol (HTTP or HTTPS), IP address, port, and optional host name. Sites can have multiple bindings if it requires different protocols or binding information.
Here’s an example of a site which is the Default Web Site that’s setup on IIS by default:
If you are going to host multiple sites on a server, it’s a good idea to create different sites for each one in IIS so that they can have different application pools and bindings if necessary.
An application is a container that consists of a group of files that deliver content or services on the web. It typically belongs to a specific application pool, which allows it to be seperated from other applications on the web server.
Here’s an example of an application named RideXpress that’s been added to the Default Web Site:
When you create an application in IIS, the application’s path becomes part of the site’s URL. For example, since RideXpress was added to Default Web Site and the site is using the default binding over port 80, the URL to RideXpress would look something like this:
http://hostname/RideXpress where hostname would be the actual name of the web server.
A virtual directory is a directory name specified in IIS to map to a physical folder located on a local or remote server. Once mapped, the directory name becomes a part of the application’s URL. Users can enter the URL in a browser to access the content that’s in the folder.
The content in the folder can be a web page, a list of files, or other folders nested within the folder as well.
Each application will have a virtual directory which is named the root virtual directory. It maps the application to the physical directory where all of the application’s files and content is located. An application can have more than one virtual directory.
As an example, say you want your application to include some other media files from another folder location that’s not included in the application’s physical directory. You can create and use a virtual directory to point to the folder where the media is located.
Here’s a virtual directory named Media that was added to the RideXpress application:
The actual file path is located directly in the C: drive, which is seperate from the application’s physical directory:
Since the virtual directory was named as Media, this is how it would appear in the URL: