从 IIS 获取应用程序池列表

发布于 2024-11-06 09:42:12 字数 94 浏览 0 评论 0原文

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

谢谢

I'm using vb.net 3.5 with asp.net and I need to list all AppPools names from IIS and show them in dropdownlist.
any help please ?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱情眠于流年 2024-11-13 09:42:12

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

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

finally I found the solution and here is the methods it could help ..

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文