32

When you create a new website on IIS, you get to choose between an "Application" and a "Virtual Directory". What is the difference between those two options?

cllpse
  • 21,396
  • 37
  • 131
  • 170

3 Answers3

29

A virtual directory is just a pointer to where web pages are stored.

An Application reserves memory in IIS for your web pages. If you are attempting to run ASP pages and plan to make use of session variables and the such then you must use an application. An Application can make use of a virtual directory or it may just exist within the default web site directory (inetpub/wwwroot/)

Emad Armoun
  • 1,625
  • 2
  • 19
  • 32
Jay
  • 2,644
  • 1
  • 30
  • 55
  • 5
    +1 But note that this isn't the end of the story, since it is not the application pool that stores the session variables, instead it is the w3wp.exe process, and if the application pool is setup to use more then one w3wp.exe (aka a "web garden") then one has to use OutProc sessions (since different requests by the same user might be routed to different processes), but you are right that the w3wp.exe is based on the application pool and not on a virtual directory – yoel halb May 18 '12 at 20:32
24

There are a few differences, here are the biggest:

  • In IIS 6 and up, you can assign an application a certain "protection" level. (e.g. protection levels, application pools, etc). You can't do this with Virtual Directories
  • If you are working with ASP.NET, the search for the master "Web.config" file for your application stops at your application level. For a working directory it will actually check your parent hierarchy for settings as well.

These are the two biggest differences in my opinion, although there are other small ones as well.

Mike Marshall
  • 7,788
  • 4
  • 39
  • 63
  • mjmarsh, you are wrong. I see in IIS 7, that you can configure "Connect as specific user or application user settings for both virtual directory as well as application. – Jasmine Nov 23 '13 at 06:05
  • 3
    I was talking about process isolation. I see that you can set the credentials to be used when accessing the virtual directory file resources but I see no way to associate a virtual directory with an application pool (other than to set it at its parent application level) – Mike Marshall Nov 25 '13 at 18:27
1

From the point of view of a web developer:

A virtual directory is the IIS 5 (Windows 2000 and earlier) container for HTML content. A virtual directory can also be configured to allow the interpretation of Active Server Pages (ASP) scripts and/or the execution of Common Gateway Interface (CGI) applications. A virtual directory CANNOT host an ASP.Net web application.

The "application" container type was introduced with IIS 6 (Windows XP / Windows Server 2003 and later). It allows for hosting of ASP.Net web applications.