【问题标题】:How to get the host/IP and port of a website iis 6-7?如何获取网站 iis 6-7 的主机/IP 和端口?
【发布时间】:2013-01-12 19:28:45
【问题描述】:

这是我的问题。我希望我可以列出本地托管的所有 IIS 网站。对于每个我想检索的站点名称,主机名 ex。 ("localhost:80") 和端口号。 我可以检索很多信息,但找不到有关主机名的信息在哪里。 非常感谢。

这是我的代码 [c#]:

DirectoryEntry iis = new DirectoryEntry("IIS://" + Environment.MachineName + "/w3svc");

        iis = new DirectoryEntry("IIS://" + Environment.MachineName + "/w3svc");

        foreach (DirectoryEntry site in iis.Children)
        {

            if (site.SchemaClassName == "IIsWebServer") 
            {
                Console.Out.WriteLine(site.Name);
                //I do not know the name of the property to find the "host"
                Console.Out.WriteLine(site.Host); ???

            }
        }

【问题讨论】:

    标签: c# .net iis host directoryentry


    【解决方案1】:

    我认为您需要将其从 ServerBindings 属性中解析出来。格式为 IP:Port:Hostname - 如果是默认网站,则 Hostname 应为空白或 *。

    还有SecureBindings,您也需要获取它(因为您需要端口号)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      • 1970-01-01
      • 2018-09-23
      相关资源
      最近更新 更多