0

My IIS website has several applications. All the applications, including the application at the site’s root, are ASP.NET applications.

When the root application is published (from Visual Studio), not only does it restart, but also all the other applications on the website. I believe the other applications restart because ASP.NET causes their Web.config’s to be dependent upon the root Web.config. Therefore, when the root Web.config is published, all applications automatically restart.

Is it possible to publish the root application without causing the other applications to restart? If so, how? If not, are there any good work-arounds?

1 Answer 1

1

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.

5
  • Hi Jose. I'm not sure what you meant by "unique virtual server" and "virtual apps", but the website is running on a virtual machine and the website does have applications and virtual folders. The root application shares the same application pool as some of the other applications on the website. I'll give the root app its own app pool and report back if that resolves the problem. Mar 25, 2019 at 13:50
  • Hi: In IIS, every site has been traditionally called a "virtual server", and I noticed that the correct term now is simply "Site", sorry. Inside a "site", apart of the default app you can add "virtual apps" that are exposed as folders for your base app but can have a different app pool assigned and configuration. They can be isolated from each other or not. In this image you can see what I mean (taken from one of my servers). I don't know if your site has a structure similar to this one. Can you attach a screen capture of it like the one I've used?
    – jalarcon
    Mar 25, 2019 at 17:17
  • Hi again, Jose. As promised, I moved the root app to its own app pool and published the app. Unfortunately, the other apps still restarted. It still seems like the other apps' dependency upon the root Web.config is the issue. Mar 26, 2019 at 20:36
  • I looked at the screen snapshot you provided and mine is much like yours. What you are calling "Virtual Server / Site" I have been calling "root application" (or "root app"). Also, your "Virtual Apps" are my "other applications" (or "other apps"). Mar 26, 2019 at 20:37
  • OK, I was missing the point, sorry. I'm going to rewrite my answer, but I'm afraid there's no way to prevent this AFAIK.
    – jalarcon
    Mar 27, 2019 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.