There are two things to consider when running an ASP.NET web app under IIS: The Application Pool and the AppDomain.
The Application Pool is related to how IIS isolates processes, and the AppDomain is how ASP.NET isolates its own processes.
The IIS App pools can be reset/restarted manually or automatically (by number of requests, time, memory constrains...).
The ASP.NET AppDomains can be restarted automatically by changing the web.config, deleting a folder, changing a .dll under bin
, and many other situations.
If you have a root app and a virtual app (seen as a subfolder in IIS) and both of them are allocated under different app pools in IIS, they can be restarted and managed independently. And they will run under different Appdomains but within the same root Appdomain in ASP.NET.
So, for example, let's create a new Site in IIS called "rootapp" and assign an app pool to it called "rootapppool". Then let's add a virtual app to it called "virtualapp" that points to a different folder with other files for a different ASP.NET app. This virtual app will hace it's own app pool assigned "virtualapppool".
With this setup you can restart each app pool independently without affecting each other. That's great for automatic restarts by number of requests, memory usage...
And both apps will have different ASP.NET AppDomains too. For example the root app will run under the AppDomain called /LM/W3SVC/6/ROOT-1-131981549187680126
and the virtual app under a different AppDomain called '/LM/W3SVC/6/ROOT/virtualapp-1-131981543771263306'.
You can get this name by calling System.Threading.Thread.GetDomain().FriendlyName
in your code.
However, note that both AppDomains share the same AppDomain root. Than means that, although you can restart the virtual app's AppDomain without affecting the root's, if you restart the root's AppDomain it forces the restart of the virtual app's.
So, to sum it up:
- The ASP.NET AppDomain can be restarted without restarting the IIS AppPool. If you restart the AppPool, a new AppDomain gets created.
- You can reset/restart any IIS AppPool without affecting the others. For example, in our sample setup you could restart the AppPool without restarting the virtual app one and the other way around.
- You can reset the AppDomain of a sub-app without affecting the root AppDomain or the ones for other virtual apps. However you can't reset the root's AppDomain without creating new AppDomains for the virtual apps.
This last thing is what's happening in your case. Although the apppools are not restarting, when you change the web.config
in the root, new AppDomains are being created for the root and for the rest of the virtual apps too.
This is how ASP.NET works and as far as I know there's no way to change it.
If you need to be aware of this and take some actions when it happens you can subscribe to the AppDomain.DomainUnload event for each AppDomain and do what you need to do.