Microsoft.Web.Administration Confusion

Just a quick tip — if you’re having problems with programmatically modifying your IIS sites configuration using the Microsoft.Web.Administration .NET API, and are currently banging your head against the desk because:

  • ServerManager.Sites returns a completely different set of sites than what is visible in IIS Manager, or
  • No matter how many times you call it, ServerManager.CommitChanges() does not seem to have any visible effect

… then make sure you’re referencing the correct Microsoft.Web.Administration.dll assembly.

Assembly Version Location
Microsoft.Web.Administration.dll v7.0.0.0 C:WindowsSystem32inetsrv
Microsoft.Web.Administration.dll v7.9.0.0 GAC

What’s the difference? Except for the version number, the two asssemblies look identical, except one (7.9.0.0) only affects IIS Express. You must use v7.0.0.0 if you want to modify IIS. Watch out!