Code代码片断(5do8)

GDI+控件线程IO流ADO.NET接口类,函数语法

新主题
c#分析 meta标签
lucene.net高亮,查询
7zip压缩cookie
lucene.net一个建立,查询...
c#获取IP
lucene.net 教程
c#汉字转拼音
.net json 范例
c#格式化日期
获取IIS的所有网站信息
说话自由

首页 » .NET/C# » 类,函数 »

获取IIS的所有网站信息

标签: DirectoryEntry IIS Properties

        //遍厉IIS列表
        DirectoryEntry directoryEntry = new DirectoryEntry(@"IIS://localhost/W3SVC");
        foreach (DirectoryEntry Entry in directoryEntry.Children) {
            PropertyCollection Properties = Entry.Properties;
            //Response.Write((string)Properties["ServerComment"].Value);
            Response.Write( Entry.Path);    
        
        }
        IEnumerator ienum = directoryEntry.Children.GetEnumerator();
        while (ienum.MoveNext())
        {

            DirectoryEntry entrypool = (DirectoryEntry)ienum.Current;
            System.DirectoryServices.PropertyCollection ppC = (System.DirectoryServices.PropertyCollection)entrypool.Properties;
            //IDictionaryEnumerator  idenum = ppC.GetEnumerator();
            foreach(PropertyValueCollection k in ppC.Values ){
                foreach(object p in k)
                    Response.Write(p.ToString()+"<br/>");
            
            }
           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();//运行状态                

            }


将返回一系列的值,但是没有网站物理路径,可以修改和设置HTTP状态值。

ccdot写于2008-7-20 13:01:27

如果愿意,请留下你观点或者感受...
称呼*
内容*
验证码*