是否有 .NET 库或 API 可以与 IIS 配置数据库交互/编辑它?

发布于 2024-07-09 06:47:15 字数 636 浏览 7 评论 0原文

...或者我是否坚持使用自己的“XML 切割”功能。 我想创建一个小型任务托盘应用程序,以便我可以快速将虚拟目录重新指向硬盘上的几个文件夹之一。

背景知识

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

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

我们的应用程序与我安装的第 3 方 CMS 集成,

http://localhost/cms/

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

http://localhost/app/

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

...or am I stuck rolling my own "XML chopping" functions. I'd like to create a small tasktray app so I can quickly re-point a Virual Directory to one of several of folders on my harddisk.

Bit of background:

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 app integrates with a 3rd party CMS which I've installed at

http://localhost/cms/

In order to work our app has to live at the same root directory. so:

http://localhost/app/

Depending on the branch I'm working on, I'm re-pointing the /app/ directory to one of the 3 paths listed above by going into IIS Manager. Just thought it'd be handy to have a quick-app to do it for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

满天都是小星星 2024-07-16 06:47:15

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

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

Ok...this isn't a tray app but you can run it from the command line. Just change the physical paths as necessary:

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 as in:

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

etc

情归归情 2024-07-16 06:47:15

我自己没有使用过这个,所以我不能 100% 确定它能解决你的问题。 但看看 .NET 中的 System.DirectoryServices。 它可以访问 IIS。

DirectoryServices 的 MSDN 帮助

I haven't used this my self, so I'm not 100% sure it will solve your problem. But take a look at System.DirectoryServices in .NET. It can access IIS.

MSDN help for DirectoryServices

天邊彩虹 2024-07-16 06:47:15

那么,对于 IIS 7,有一个 .NET 包装器可以通过 .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

Well, for IIS 7, there is a .NET wrapper to enable IIS management via .NET. See this link for details,

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文