zoukankan      html  css  js  c++  java
  • asp.net(c#)获取iis的站点信息(转)

            protected void Page_Load(object sender, EventArgs e)
            {
                DirectoryEntry directoryEntry = new DirectoryEntry(@"IIS://localhost/W3SVC");
                IEnumerator ienum = directoryEntry.Children.GetEnumerator();
                string HostInfo = "";
                while (ienum.MoveNext())
                {
                    DirectoryEntry entrypool = (DirectoryEntry)ienum.Current;
                    System.DirectoryServices.PropertyCollection ppC = (System.DirectoryServices.PropertyCollection)entrypool.Properties;
                    IDictionaryEnumerator idenum = ppC.GetEnumerator();
                    if (entrypool.SchemaClassName == "IIsWebServer")
                    {
                        string[] serverBind = ppC["ServerBindings"][0].ToString().Split(':');//获取网站绑定的IP,端口,主机头
                        string EnableDeDoc = ppC["EnableDefaultDoc"][0].ToString();
                        string DefaultDoc = ppC["DefaultDoc"][0].ToString();//默认文档
                        string MaxConnections = ppC["MaxConnections"][0].ToString();//iis连接数,-1为不限制
                        string ConnectionTimeout = ppC["ConnectionTimeout"][0].ToString();//连接超时时间
                        string MaxBandwidth = ppC["MaxBandwidth"][0].ToString();//最大绑定数
                        string ServerState = ppC["ServerState"][0].ToString();//运行状态
    
                        HostInfo += "站点描述:" + ppC["ServerComment"][0].ToString() + "<br>IP地址:" + serverBind[0].ToString() + "<br>TCP端口:" + serverBind[1].ToString() + "<br>主机头:" + serverBind[2].ToString() + "<br>";//获取IIS下所有站点名称
                        HostInfo += "启用默认文档:" + EnableDeDoc + "<br>";
                        HostInfo += "默认文档:" + DefaultDoc + "<br>";
                        HostInfo += "最大连接:" + MaxConnections + "<br>";
                        HostInfo += "连接超时:" + ConnectionTimeout + "<br>";
                        HostInfo += "最大绑定数:" + MaxBandwidth + "<br>";
                        HostInfo += "运行状态:" + ServerState + "<br><br>";
                    }
                }
                Response.Write(HostInfo);
                Response.End();
            }
  • 相关阅读:
    洛谷P1628 合并序列
    洛谷 P1334 瑞瑞的木板==P2664 【题目待添加】
    洛谷P1090 合并果子
    洛谷P3378 【模板】堆
    codevs 3129 奶牛代理商IX
    codevs 3344 迷宫
    codevs 2549 自然数和分解
    codevs 3096 流输入练习——寻找Sb.VI
    洛谷 P1821 [USACO07FEB]银牛派对Silver Cow Party
    洛谷 P1629 邮递员送信
  • 原文地址:https://www.cnblogs.com/freezing/p/3010295.html
Copyright © 2011-2022 走看看