What’s the difference between Web App and Virtual Folder in the context of IIS 7.x?

A Virtual Folder or Virtual Directory is just a link to a physical folder somewhere on the server. This folder becomes part of the website structure and you can use the virtual directory in the path part of URLs. Code that executes in Virtual Directories will execute in the same “Application” as it’s parent.

An Application is where the code that runs inside that “folder” has it’s own Session state and Application state. It is in effect a new standalone application living underneath the root application.

For example, if you were to deploy an ASP.NET application into a site that had an Application folder called /myapp then that application would have it’s own application domain, session state, application state completely separate from another ASP.NET application running in /. For example: if you set an Application value Application["Thing"] = 123 in the root application and then did the same but with a different value in /myapp then Application["Thing"] in the root would not be overwritten by the assignment in /myapp.

Another thing you can do with Application’s is specify a different Application Pool to run under. For example your root / application might contain an ASP.NET 2.0 application and run in a pool configured for .NET 2.0. However you may want to run a blog or forum application written in ASP.NET 4.0. Now because you can’t mix ASP.NET runtime versions in the same application pool, you can specify an alternative application pool specifically for ASP.NET 4.0 applications.

Applications can also behave like Virtual Directories and you can point an application folder at a physical folder elsewhere on the server.

If you’re interested in the underlying mechanics of Virtual Directories and Applications on IIS7 then have a look at this answer I posted a while back:

Using ServerManager to create Application within Application

Leave a Comment