using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.DirectoryServices;
public partial class _Default : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
//注意网站 与 虚拟目录的属性不一样的 path不同
DirectoryEntry dir = new DirectoryEntry("IIS://localhost/w3svc");
foreach (string elmentName in dir.Properties.PropertyNames)
...{
PropertyValueCollection valueCollection = dir.Properties[elmentName];
for (int i = 0; i < valueCollection.Count; i++)
...{
this.Response.Write(elmentName + "[" + i.ToString() + "] =" + valueCollection[i].ToString() + "<br/>");
}
}
}
}
本文介绍了一个使用ASP.NET来遍历并显示IIS服务器上特定目录的属性的方法。通过DirectoryEntry类获取“IIS://localhost/w3svc”路径下的所有属性,并将其输出到网页上。这有助于理解如何在.NET环境中与IIS进行交互。
280

被折叠的 条评论
为什么被折叠?



