.NET 获取IIS中网站名称和属性
//遍厉IIS
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"].ToString().Split(':');//获取网站绑定的IP,端口,主机头
string EnableDeDoc = ppC["EnableDefaultDoc"].ToString();
string DefaultDoc = ppC["DefaultDoc"].ToString();//默认文档
string MaxConnections = ppC["MaxConnections"].ToString();//iis连接数,-1为不限制
string ConnectionTimeout = ppC["ConnectionTimeout"].ToString();//连接超时时间
string MaxBandwidth = ppC["MaxBandwidth"].ToString();//最大绑定数
string ServerState = ppC["ServerState"].ToString();//运行状态
HostInfo += "站台名称:" + ppC["ServerComment"].ToString() + "-- 网站IP:" + serverBind.ToString() + "--网站端口:" + serverBind.ToString() + "--主机头" + serverBind.ToString() + "<br>";//获取IIS下所有站点名称
HostInfo += EnableDeDoc + "<br>";
HostInfo += DefaultDoc + "<br>";
HostInfo += MaxConnections + "<br>";
HostInfo += ConnectionTimeout + "<br>";
HostInfo += MaxBandwidth + "<br>";
HostInfo += ServerState + "<br>";
}
}
Response.Write(HostInfo);
Response.End();小弟现在在研究IIS,有兴趣的朋友可以一起探讨下...上面只是获取最基本的信息.IIS提供了很多属性,小弟在此没有一一列举..........
小弟遇到一问题:如何在IIS里面限制主机头的最大值,可是IIS属性里面有提供..
页:
[1]