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:\Windows\System32\inetsrv\
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 ( only affects IIS Express. You must use v7.0.0.0 if you want to modify IIS. Watch out!

2 thoughts on “Microsoft.Web.Administration Confusion

  1. omg thanks , took me hours to understand why in my last project everything worked perfect , but it new project , allmost same code , IIS didn’t show any changes on commit !

Comments are closed.