代码之家  ›  专栏  ›  技术社区  ›  Eoin Campbell

有没有。NET库或API与IIS元数据库交互/编辑IIS元数据库?

  •  4
  • Eoin Campbell  · 技术社区  · 17 年前

    …或者我一直在滚动自己的“XML斩波”函数。我想创建一个小型任务栏应用程序,这样我就可以快速地将虚拟目录重新指向硬盘上的几个文件夹之一。

    背景介绍:

    在我的开发机器上,我们的代码库有3个不同的svn分支。

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

    我们的应用程序与我安装在

    http://localhost/cms/
    

    为了正常工作,我们的应用程序必须位于同一根目录中。所以:

    http://localhost/app/
    

    根据我正在处理的分支,我将重新指向 /app/ 通过进入IIS管理器,将目录切换到上面列出的3个路径之一。只是觉得有一个快速的应用程序来帮我做这件事会很方便。

    3 回复  |  直到 17 年前
        1
  •  3
  •   erlando    12 年前

    好的……这不是一个托盘应用程序,但你可以从命令行运行它。只需根据需要更改物理路径:

    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;
            }
          }
        }
      }
    }
    

    然后按如下方式运行:

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

    以及其他

        2
  •  1
  •   Magnus Westin    17 年前

    我自己还没有用过这个,所以我不能100%确定它能解决你的问题。但是看看系统。中的目录服务。网。它可以访问IIS。

    MSDN help for DirectoryServices

        3
  •  1
  •   Lex Li    17 年前

    对于IIS 7,有一个。NET包装器,通过启用IIS管理。网。有关详细信息,请参阅此链接,

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

    对于IIS的早期版本(5或6),提供了ADSI和WMI接口,

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

    推荐文章