如何以编程方式使用应用程序池作为模板

时间:2014-06-05 12:44:31

标签: c# iis iis-6

在IIS6中,通过IIS6 Manager创建新的应用程序池时,您可以选择使用现有的应用程序池作为模板。有没有办法以编程方式执行此操作?我一直在Windows 2003 Enterprise Server上查看目录服务。我有代码以编程方式创建网站,应用程序池和虚拟目录,但无法确定如何解决此问题。

编辑: 这就是我用C#使用System.DirectoryServices命名空间将属性和设置从一个应用程序池复制到另一个应用程序池的方法。此示例使用默认应用程序池作为模板。我想我会在其他人需要这样做的时候分享它:

using System.DirectoryServices;

DirectoryEntry DefaultAppPool = new DirectoryEntry(@"IIS://localhost/W3SVC/AppPools/DefaultAppPool");

DirectoryEntry root = new DirectoryEntry(@"IIS://localhost/W3SVC/AppPools");

DirectoryEntry newAppPool = root.Invoke("Create", "IIsApplicationPool", "FOO") as DirectoryEntry;

newAppPool.CommitChanges();

DefaultAppPool.CopyTo(newAppPool);

0 个答案:

没有答案
相关问题