简体   繁体   English

我可以使用DirectoryEntry在IIS Express中列出站点吗

[英]Can I use DirectoryEntry to list sites within IIS Express

I am on Windows XP. 我在Windows XP上。 We have Windows 2008 Servers. 我们有Windows 2008服务器。 Need to run IIS Express until we get workstations or virtual machines with newer version of local OS for the real IIS 7.X. 需要运行IIS Express,直到获得具有用于实际IIS 7.X的较新版本的本地操作系统的工作站或虚拟机为止。

Can I use DirectoryEntry to list my Sites and Virtual Directories when I run c# code under IIS Express? 在IIS Express下运行c#代码时,可以使用DirectoryEntry列出我的站点和虚拟目录吗? I have examples for setting up the Virtual Directories under IIS Express so that I think I have covered. 我有一些在IIS Express下设置虚拟目录的示例,因此我认为已经介绍了。 Now I want to list them to ensure they exist. 现在,我想列出它们以确保它们存在。

Anyone know how to do this in C#? 有人知道如何在C#中执行此操作吗? Just a small snippet of what I have been trying causes com exceptions... 我尝试的一小段代码会导致com异常...

DirectoryEntry iisServer = new DirectoryEntry("IIS://localhost/W3SVC/1");
DirectoryEntry folderRoot = iisServer.Children.Find("Root", "/");
var children = folderRoot.Children;

you can try something like this 你可以尝试这样的事情

void ListVirtualDirectories(string serverName, int siteId)
{            
       DirectoryEntry iisServer = new DirectoryEntry("IIS://" + serverName + "/W3SVC/" + siteId + "/ROOT");

       foreach (DirectoryEntry webDir in iisServer.Children)
       {
           if (webDir.SchemaClassName.Equals("IIsWebVirtualDir"))
               Console.WriteLine("Found virtual directory {0}", webDir.Name);
       }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在IIS中通过DirectoryEntry减少与AD的连接? - How should I reduce connections to AD with DirectoryEntry within IIS? 如何从Visual Studio 2015中启用IIS Express中的详细错误 - How can I enable detailed errors in IIS Express from within Visual Studio 2015 DirectoryEntry IIS访问权限 - DirectoryEntry IIS access permission 如何使用 ServerManager 从类库中读取 IIS 站点,而不是 IIS express,或者提升的进程如何处理类库? - How to use ServerManager to read IIS sites, not IIS express, from class library OR how do elevated processes handle class libraries? 当我启动asp.net应用程序时,IIS Express会启动正在运行的网站的副本 - When I launch an asp.net application, IIS Express launches duplicates of running sites iis控制台应用程序目录条目搜索结果 - iis console application directoryentry searchresult 如何使用c#在ASPX页面中获取IIS中的网站列表? - How can i get a list of the websites in IIS from within a ASPX page using c#? 如何使用DirectoryEntry(“ IIS:// Localhost / W3SVC”)更改具有多个主机标头条目的IP地址 - How to use DirectoryEntry(“IIS://Localhost/W3SVC”) to change IP address with several host header entries LDAP或WinNT中的DirectoryEntry。 我怎么知道 - DirectoryEntry from LDAP or from WinNT. How can I know it? 如何从 AD DirectoryEntry 获取 DOMAIN\\USER? - How can I get DOMAIN\USER from an AD DirectoryEntry?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM