Получить список AppPools из IIS - PullRequest
0 голосов
/ 11 мая 2011

Я использую vb.net 3.5 с asp.net, и мне нужно перечислить все имена AppPools из IIS и показать их в выпадающем списке.любая помощь, пожалуйста?

спасибо

1 Ответ

1 голос
/ 11 мая 2011

наконец я нашел решение и вот методы, которые могут помочь ..

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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...