ASP.NET uses the ReadDirectoryChangesW Win32 function to monitor directories and files. In the following scenarios, the ASP.NET AppDomain class is unloaded:
- The application's physical root path and all of its subdirectories are monitored for subdirectory name changes or deletions. The AppDomain is unloaded if any of these change.
- The "bin," "App_Code," "App_WebReferences," "App_GlobalResources," and "App_Browsers" subdirectories of the application root folder are monitored for creation, deletion, renaming, ACL changes, changes to the last-write time, and changes to the size. If any of these things change, the AppDomain is unloaded.
- The machine.config and root web.config files are monitored for changes. A change to either of these files will unload the AppDomain.
- The web.config file of parent applications is monitored. A change to this file will unload the AppDomain.
- The web.config file in the application root is monitored. A change to this file will unload the AppDomain.
- The hash.web file that's located in the "hash" subdirectory of the Temporary ASP.NET Files folder is monitored. This monitoring was added to support development scenarios in which both the ClientBuildManager and the runtime BuildManager are updating the application files. Because there are two build managers, there was a need to keep them in sync, and the hash.web file is used for that purpose.
- The web.config file in any subdirectory of the application is monitored. A change to this file will unload the AppDomain.
- The "App_LocalResources" subdirectory of each virtual subdirectory is monitored for creation, deletion, renaming, ACL changes, changes to the last-write time, and changes to the size. If any of these things change, the AppDomain is unloaded.
Antivirus software that scans these aforementioned folders could trigger a FileChangeNotification and cause the AppDomain to be unloaded. These folders should be excluded from antivirus scanning to avoid production runtime AppDomain unloads that may, in turn, cause severe performance issues.
Based on the files and folders that are monitored, the following directories are recommended for exclusion from antivirus scanning:
- The root directory and all of its subdirectories for the ASP.net application.
- The .NET Framework config files directory. This varies by the version of .NET Framework and on whether the ASP.NET application is running in 32-bit or 64-bit processes.
- The root directory of the ASP.NET application's parent application.
- The Temporary ASP.NET Files folder.
We also recommend that the following IIS directories be excluded from antivirus scans in ASP.NET applications:
Article ID: 3126034 - Last Review: Mar 16, 2016 - Revision: 1