c# - 如何在c#代码中在iis 5.1中添加新的应用程序池?

标签 c# windows-xp application-pool iis-5 directoryentry

我正在尝试在 IIS 5.1 上添加网站

当我尝试使用下面的函数为我的新网站创建应用程序池时,我遇到了这个奇怪的错误“system.directoryNotFound Exception ... in CreateAppPool”

最奇怪的是,应用程序池的创建功能在带有 IIS7 的 Windows 7 电脑上完美运行,但在带有 ISS5.1 的 Windows XP 上却不起作用 下面的路径“IIS://localhost/W3SVC/AppPools”在IIS5.1上有什么不同吗?

public static CreateAppPool(string name)
        {
            string machineName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
            DirectoryEntry Service = new DirectoryEntry("IIS://"+machineName+"/W3SVC/AppPools");

            // create new app pool
            DirectoryEntry appPool = Service.Children.Add(name, "IIsApplicationPool");
            appPool.CommitChanges();
            Service.CommitChanges();

        }

最佳答案

您无法在 IIS 5 中创建应用程序池,但您可以在默认网站下创建一个新的虚拟目录并将其设为应用程序。

关于c# - 如何在c#代码中在iis 5.1中添加新的应用程序池?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14237693/

相关文章:

windows-xp - Windows XP 上的 Microsoft.Web.Administration

powershell - 使用强制选项在Powershell中创建应用程序池

iis - 断言 User.Identity.Name 已在我的 MVC 应用程序中正确设置

c# - 线程窗体

visual-studio - 在 Windows 7 而不是 Windows XP 上运行 Visual Studio 2010 的优势

c++ - 在windows xp上用VS 2012编译MFC程序

iis - 在 ASP.Net Core 中设置(或不设置).NET CLR 版本有什么影响?

c# - 如何同步三个arrayLists的排序

c# - 将 JSON 对象层次结构反序列化为 Dictionary<string, object> 的层次结构

c# - 如何在内容中实现文本文件 (XNA)