Is there a .NET library or API for interacting with / Editing the IIS metabase?

... or I am fixated on my own XML chopping features. I would like to create a small tasktray application so that I can quickly reassign the Virual Directory to one of several folders on my hard drive.

Background Bit:

I have 3 different svn branches of our code base on my dev machine.

Current Production Branch ( C:\Projects\....\branches\Prod\ ) Next Release Canidate Branch ( C:\Projects\....\branches\RCX\ ) Trunk ( C:\Projects\....\trunk\ ) 

Our application integrates with a third-party CMS that I installed on

 http://localhost/cms/ 

To work, our application must live in the same root directory. So:

 http://localhost/app/ 

Depending on the branch I'm working on, I will redirect the /app/ directory to one of the three paths listed above by going to IIS Manager. Just thought it would be convenient to have a quick application to do this for me.

+4
source share
3 answers

Ok ... this is not a tray application, but you can run it from the command line. Just change the physical paths as needed:

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; namespace Swapper { class Program { static void Main(string[] args) { using (DirectoryEntry appRoot = new DirectoryEntry("IIS://Localhost/W3SVC/1/root/app")) { switch (args[0].ToLower()) { case "prod": appRoot.Properties["Path"].Value = @"e:\app\prod"; appRoot.CommitChanges(); break; case "rcx": appRoot.Properties["Path"].Value = @"e:\app\rcx"; appRoot.CommitChanges(); break; case "trunk": appRoot.Properties["Path"].Value = @"e:\app\trunk"; appRoot.CommitChanges(); break; default: Console.WriteLine("Don't know"); break; } } } } } 

Then run like:

 C:\>swapper prod C:\>swapper rcx 

etc.

+3
source

I have not used this myself, so I am not 100% sure that it will solve your problem. But look at System.DirectoryServices in .NET. He can access IIS.

MSDN Help for DirectoryServices

+1
source

Well, for IIS 7, there is a .NET wrapper that allows you to manage IIS through .NET. See this link for details.

http://learn.iis.net/page.aspx/165/how-to-use-microsoftwebadministration/

For the previous version of IIS (5 or 6), ADSI and WMI interfaces are provided,

http://msdn.microsoft.com/en-us/library/ms525885.aspx

+1
source

All Articles