【问题标题】:Get List of AppPools from IIS从 IIS 获取 AppPool 列表
【发布时间】:2011-05-11 10:24:12
【问题描述】:

我将 vb.net 3.5 与 asp.net 一起使用,我需要列出 IIS 中的所有 AppPools 名称并将它们显示在下拉列表中。 请问有什么帮助吗?

谢谢

【问题讨论】:

    标签: iis application-pool


    【解决方案1】:

    我终于找到了解决方案,这里是它可以提供帮助的方法..

    Public Function GetAppPoolNames() As List(Of String)
        Dim Root As System.DirectoryServices.DirectoryEntry = GetDirectoryEntry("IIS://localhost/W3SVC/AppPools")
        'DirectoryEntry Root = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
        Dim AppList As New List(Of String)
        If Root Is Nothing Then
    
        Else
            For Each dir As DirectoryEntry In Root.Children
                Dim pr As System.DirectoryServices.PropertyCollection = dir.Properties
                'ApplicationPool pool = new ApplicationPool();
                'pool.Name = dir.Name;
                'DropDownList1.Items.Add(pool.Name);
                AppList.Add(dir.Name)
            Next
    
        End If
        Return AppList
    End Function
    Private Function GetDirectoryEntry(ByVal path As String) As DirectoryEntry
        Dim root As DirectoryEntry = Nothing
        Try
            root = New DirectoryEntry(path)
        Catch
            'Console.WriteLine("Could not access Node")
            Return Nothing
        End Try
        If root Is Nothing Then
            'Console.WriteLine("Could not access Node")
            Return Nothing
        End If
        Return root
    End Function
    

    【讨论】:

      猜你喜欢
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 2015-07-25
      • 1970-01-01
      • 1970-01-01
      • 2016-12-06
      • 1970-01-01
      相关资源
      最近更新 更多