Half-Blood Programmer

What’s Microsoft.Web.Administration and The Horrible Facts You Should Know

I know many of you learned about IIS extensibility and came across MWA. There are not so many articles on IIS.net about it (as well as MWM), such as

http://www.iis.net/learn/develop/extending-the-management-ui/overview-of-mwa-and-mwm-for-iis

http://www.iis.net/learn/develop/extending-iis-configuration/extending-iis-schema-and-accessing-the-custom-sections-using-mwa

Explore them and you can see how cool it is to control IIS via a purely C# friendly API. I will let Microsoft guide you further on what is MWA, as I am just going to cover the horrible facts, which reveals to you how misunderstanding (sometimes I even called it stupidity) can lead to significant problems.

MWA is OS Dependent

The second link above (and many other high quality resources) shows you how to add MWA assembly to your project reference list. It must be added from %SystemRoot%\system32\inetsrv. And that’s the ONLY way. Although IIS 7.0/7.5/8.0/8.5/10.0 look similar, they ship different versions of MWA, which are not designed to be used for each other.

The technical reasons behind that are,

  • MWA is a wrapper over IIS COM interfaces. It is not something you can xcopy.
  • MWA API can change slightly so as to support new features in later releases (such as adding new enumeration items to support SNI and so on).

None of MWA on NuGet.org Is Official

You could hardly understand how NuGet is popular until you see the Microsoft.Web.Administration package at NuGet.org has been downloaded more than 100,000 times. But YOU MUST NOT USE THEM, ANY OF

http://www.nuget.org/packages?q=microsoft.web.administration

I contacted the publisher alexey.petriashev and asked him to remove that package. No reply.

I contacted NuGet.org to remove that package. They replied that they could not.

I even saw other Microsoft involved discussions about those NuGet packages, but still nobody would like to remove them.

Why everyone wants to create more pains and complaints instead of simply emphasize the correct approach?

Other Tiny Problems

Comparing to the above, they seem to be so tiny, but still noticeable,

  1. ServerManager.CommitChanges returns before the changes actually take effect.
  2. Typically any code with MWA should be executed under a local administrator account.
  3. Some collections just do not support remove or clear operations. My hack is to replace the whole collection instance.
  4. Some APIs are schema based, while some are completely out of documentation. May the force be with you and good luck.

Last but not least, I am working on a fully managed implementation of MWA as part of the Jexus Manager project. More information on that will come unexpectedly on this blog, so stay tuned.

(Updated on Feb 10, 2016: The Jexus Manager version of Microsoft.Web.Administration is now open source, https://blog.lextudio.com/2015/12/jexus-manager-the-open-source-plan/)

Leave a Reply