Does Modifying applicationHost.config Trigger IIS7 Restart and Application Pool Recycling?


2 views

The applicationHost.config file is the root configuration file for IIS7+, located at %windir%\system32\inetsrv\config\applicationHost.config. When modified, IIS behavior depends on the specific changes made:

// Example of common modifications:
<configuration>
  <system.applicationHost>
    <applicationPools>
      <add name="MyAppPool" managedRuntimeVersion="v4.0" />
    </applicationPools>
  </system.applicationHost>
</configuration>

Changes generally fall into three categories with different restart behaviors:

  1. Hot-swappable changes: IIS detects and applies automatically (e.g., most IIS module configurations)
  2. Application pool recycling: Triggers when modifying pool settings (worker processes restart)
  3. Full IIS reset: Required for structural changes (adding/removing sites or bindings)

For reliable testing in your VM environment:

# PowerShell monitoring command
Get-EventLog -LogName System -Source "WAS" -After (Get-Date).AddMinutes(-5) | 
  Where-Object {$_.Message -like "*recycle*"} | 
  Format-Table TimeGenerated,Message -AutoSize

Here's what happens with specific modifications:

// Case 1: Changing default document (no restart)
<defaultDocument enabled="true">
  <files>
    <add value="home.html" />
  </files>
</defaultDocument>

// Case 2: Modifying app pool settings (recycles pool)
<applicationPools>
  <add name="MyPool" startMode="AlwaysRunning" />
</applicationPools>

// Case 3: Adding new site (requires iisreset)
<sites>
  <site name="NewSite" id="2">
    <application path="/" applicationPool="MyPool" />
    <bindings>
      <binding protocol="http" bindingInformation="*:80:" />
    </bindings>
  </site>
</sites>

To minimize downtime:

  • Use appcmd.exe for atomic changes instead of direct file edits
  • Schedule modifications during maintenance windows
  • Implement configuration change monitoring:
    # File system watcher in C#
    var watcher = new FileSystemWatcher(@"%windir%\system32\inetsrv\config");
    watcher.Filter = "applicationHost.config";
    watcher.NotifyFilter = NotifyFilters.LastWrite;
    watcher.Changed += OnConfigChanged;
    watcher.EnableRaisingEvents = true;
    

If experiencing unplanned restarts:

  1. Check IIS configuration change history:
    %windir%\system32\inetsrv\config\administration.config
    %windir%\system32\inetsrv\config\redirection.config
  2. Verify no overlapping configuration in web.config files
  3. Examine Windows Event Logs for WAS (Windows Process Activation Service) events

When working with IIS7 administration, the applicationHost.config file located at %windir%\system32\inetsrv\config\applicationHost.config serves as the master configuration file. A common concern among developers is whether modifications to this file will force an IIS restart and consequently recycle all application pools.

Through extensive testing (including on cloned VMs as you mentioned), I've observed that:

  • Most configuration changes do not require a full IIS restart
  • Application pool recycling depends on the specific section being modified
  • IIS implements a hierarchical configuration system with inheritance
Modified Section IIS Restart App Pool Recycle
system.applicationHost/applicationPools Yes All pools
system.webServer/security No Affected sites only
location path settings No Targeted app only

Here's a PowerShell snippet to safely test configuration changes:

# Create backup before editing
Copy-Item "$env:windir\system32\inetsrv\config\applicationHost.config" "$env:windir\system32\inetsrv\config\applicationHost.backup"

# Make changes using appcmd
appcmd set config -section:system.webServer/security/authentication/anonymousAuthentication /enabled:false /commit:apphost

# Check running state
Get-WebAppPoolState -Name "DefaultAppPool" | Select-Object Value

To minimize disruption:

  • Use appcmd or IIS Manager instead of direct file edits
  • Stage changes during maintenance windows for high-impact modifications
  • Monitor Event Viewer logs (Windows Logs > System) for configuration change events
  • Leverage the commit parameter to control where changes are saved

If you experience unintended restarts after configuration changes:

  1. Check the IIS configuration change history:
    appcmd list backup
  2. Review application pool recycling settings in:
    %windir%\system32\inetsrv\config\applicationHost.config