views:

73

answers:

2

Using IIS 6, is Application Isolation happen based on the Application Pool? If so, what happens when there is more than one Virtual Directory in one Application Pool? Do they all share the same memory and if one Virtual Directory crashes, all the other apps crash as well?

+2  A: 

If functionality in one Virtual Directory crashes, yes, it may crash or harm other applications in the same Application Pool, including those in other Virtual Directories. Protect your applications by putting them into separate Application Pools.

Virtual directories do not themselves segregate memory or resources. This has other implications as well. For example, your static variables in one application can be affected by setting static variables in another application in the same application pool.

In IIS 6, the point of an application pool is quite simple: to segregate applications so that one crashing does not bring down the rest. In IIS 7, that is still the main purpose, but there is a little more to it.

Edit: To clarify: Each Application Pool is it's own "worker process", and one crashing won't hurt other Application Pools. Each Virtual Directory is simply that: a way to make IIS act as if there was a directory at that place. When you create a Virtual Directory with the same name and location as the folder it points to, by default that doesn't really do anything. You can use virtual directories for a variety of reasons, in addition to making URL's be as you wish: You can use them for security. And you can use them to put calls into particular application pools, as we've been discussing.

People often equate Virtual Directories with Web Applications because that is usually where you want to use the configuring power of virtual directories--by web app.

Session State is only maintained within the Web Application, not amongst all the Web Applications in an Application Pool. To store values shared between different Web Applications, you'd have to do something else. The ASP.NET cache, cookies, db, etc. Putting different folders in your application as different Virtual Directories and Separate Application pools would put them in different processes and destroy their shared session state.

Patrick Karcher
If a recycle happens, does that mean it is done at the Application Pool level so all virtual directories in that app pool are restarted?
@user54064: yes, that is correct.
Patrick Karcher
Does the sharing of session state happen at the virtual directory level or the App Pool level?
As Chris Lively mentioned, it happens at the Application Pool level.
Patrick Karcher
So that is how you could share session state across multiple ASP.NET applications by putting them all in the same virtual directory? I didn't know that was possible.
Sorry the above comment should say "by putting them all in the same App Pool"
@user54064: You don't even need to put applications in different virtual directories. You can actually merge multiple asp.net web apps in the same physical directory, provided you don't have file conflicts (same file name with two different purposes).
Chris Lively
then what constitues a separate ASP.NET application? I thought they needed to be in different vitural directories.
I guess different virtual directories do not share the same Cache object even if they're sharing same application pool. Am I wrong?
hakan
+1  A: 

Different virtual directories can have different application pools. If they share the same app pool and blow up then the whole app crashes. If you have different app pools configured for the virtual directories then they are isolated.

Bear in mind that setting up different app pools for your virtual directories has other consequences such as the lack of ability to share in memory session state. In this case you have to use out-of-process storage.

Chris Lively