After a lot of work I finally have the time now to write a useful entry. Almost all the times I have spoken on IIS, I have had an audience who asked me these basic questions.
Q.)What is the difference between Virtual Directory and Virtual Application
Q.)How is ASP and ASP.NET processed within IIS.
Although they are conceptually and functionally different,yet they tend to arise a very reasonable confusion in the mind. So I thought to put the answer down in writing.
Lets take them one by one.
Q.)What is the difference between Virtual Directory and Virtual Application
Before we dig deep into the difference lets go through the definitions:
Virtual Directory is the path that you specify in IIS which maps to the physical location of the content. This path then becomes the part of the URL.
An Application in IIS 6 is a virtual directory which contains some or more of the application pool properties.This again becomes the part of the website URL.
For example, if you have a static file named
start.htm which is contained inside a folder named
example. When you map
example to a website within IIS, it becomes a
Virtual Directory. After that, once you associate an application pool to this virtual directory it becomes an
Application. But, this was within IIS 6.
With IIS 6 as prospective in mind, the concept is pretty confusing as the difference is not that major. In IIS 6, the basic purpose for this feature was application isolation. Other than this , however, it provided the developers to make complex applications by using the extended feature within ASP and ASP.Net applications.
In IIS 7 however this is pretty different, for the good :)
For IIS 7, Application and Virtual Directory are two different objects and are different parts of the website hierarchy. Within IIS 7, every site must contain an application which will in turn contain one or more virtual directory.
An
Application here is a group of files that delivers content or provides services over protocols, such as HTTP.When you create and application it is not only a part of sites but is now also mapped to an Application Pool.
The difference is more apparent when we bring in ASP.Net into the picture, as we will then have to consider the runtime component at the server. At runtime when an ASP.Net application request is received, a new AppDomain is created in the worker process that handles subsequent ASP.NET requests. Therefore, an application can have several virtual directories, and each one will be served by the same AppDomain because of the integrated pipeline structure of IIS 7.
But again you can have a set of Applications and virtual directories with in a single site. Atlast, it only depends on how you plan it out. I would recommend, the static content files to be a part of the virtual directory structure and the dynamic content which may or may not include aspx pages to be part of the application structure within a site.
Q.)How is ASP and ASP.NET processed within IIS.
Well this is a very good question, because the answer of this questions also gives you a very sound surface touch of the IIS processing model.
The description below is how ASP and ASP.Net is processed under IIS6. This process model is now pretty different in the case of IIS 7.
When a request is made by the user for an ASP page, IIS checks the given URL, determines the actual resource name, extension.
Since you have the general extension as .asp for asp web pages IIS maps that request to asp.dll. ASP.dll will process the page and return the HTML equivalent to IIS, which is then sent to the browser.
asp.dll is located at %windir%\system32\inetsrv
Oh BTW, for the beginners, if you come across the word Classic ASP (which is more or less now a standard representation.) it stand for ASP but not ASP.Net. ;)
As for ASP.NET the processing a bit more complex.... you have the general extension as .aspx for asp.net web pages, IIS maps that request to aspnet_isapi.dll. Aspnet_isapi.dll will process the page and return the HTML equivalent to IIS, which is then sent to the browser. However, for the sake of easy understanding, I have not included many features with in ASP.Net processing.
Well I leave it at this, lets see where you would want me to take it. Do put in your comments/questions as always.