直接iis 80端口 默认导航首页 ,

可以不用再记住你每个开发网站的端口了.

自动显示你的iis当前有多少站点

.点击链接就可以直达

这个程序是从我老大那里拿来的.

非常好用

using System; 
using System.Collections.Generic; 
using System.DirectoryServices; 
 
public partial class _default : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        int TotalServerCount = 0; 
        DirectoryEntry rootfolder = new DirectoryEntry("IIS://localhost/W3SVC"); 
 
        foreach (DirectoryEntry child in rootfolder.Children) 
        { 
            if (child.SchemaClassName == "IIsWebServer") 
            { 
                TotalServerCount += 1; 
            } 
        } 
 
        //循环获取所有站点详细属性写入数组中 
        Dictionary<int, string> sites = new Dictionary<int, string>(); 
        Dictionary<int, string> paths = new Dictionary<int, string>(); 
        int[] arrayServerPort = new int[TotalServerCount]; 
 
        string currentServerBindings;//绑定主机头IP端口字符串 
        char[] a = ":".ToCharArray(); 
        string[] currentBingdings = new string[2]; 
 
        int i = 0; 
        foreach (DirectoryEntry child in rootfolder.Children) 
        { 
            if (child.SchemaClassName == "IIsWebServer") 
            { 
                currentServerBindings = child.Properties["ServerBindings"].Value.ToString(); 
                currentBingdings = currentServerBindings.Split(a); 
 
                sites.Add(int.Parse(currentBingdings[1]), child.Properties["ServerComment"].Value.ToString()); 
 
                foreach (DirectoryEntry rootChild in child.Children) 
                { 
                    if (rootChild.Name.ToString().ToLower() == "root") 
                    { 
                        if (rootChild.Properties["Path"].Value == null) 
                        { 
                            paths.Add(int.Parse(currentBingdings[1]), ""); 
                        } 
                        else 
                        { 
                            paths.Add(int.Parse(currentBingdings[1]), rootChild.Properties["Path"].Value.ToString()); 
                        } 
                    } 
                } 
 
                arrayServerPort.SetValue(int.Parse(currentBingdings[1]), i); 
 
                i += 1; 
            } 
        } 
 
        Reorder(ref arrayServerPort); 
 
        //输出站点信息 
        for (i = 0; i < TotalServerCount; i++) 
        { 
            Response.Write("<span style=\"width:280px;display:block;float:left;\"><a href=\"http://localhost:" + arrayServerPort[i].ToString() + "\">站点名称: " + sites[arrayServerPort[i]] + "</a></span>"); 
            Response.Write("<span style=\"width:80px;display:block;float:left;\">端口: " + arrayServerPort[i].ToString() + "</span>"); 
            Response.Write("<span style=\"display:block;float:left;\">路径: " + paths[arrayServerPort[i]] + "</span>");  
            Response.Write("<br>"); 
        } 
    } 
 
    private void Reorder(ref int[] args) 
    { 
        int j, temp; 
        for (int i = 0; i < args.Length - 1; i++) 
        { 
            j = i + 1; 
        aa: 
            if (args[i] > args[j]) 
            { 
                temp = args[i]; 
                args[i] = args[j]; 
                args[j] = temp; 
                goto aa; 
            } 
            else 
                if (j < args.Length - 1) 
                { 
                    j++; 
                    goto aa; 
                } 
        } 
    } 
}