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 (7.9.0.0) only affects IIS Express. You must use v7.0.0.0 if you want to modify IIS. Watch out!

September 22, 2013

2 Comments

Mauro on May 21, 2014 at 6:10 pm.

What a beautiful insight.

Thanks.

LavonJun on July 14, 2014 at 8:22 am.

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 !

Leave a Reply