Solved

How to Get list of web pages in the ASP.Net website?

Posted on 2011-03-01
1
438 Views
Last Modified: 2012-06-27
Is there a way programmatically, I can get all the web pages available in my website like a map and display them in my home page or a seperate web page for this display?
0
Comment
Question by:reach_prgmmer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
AkAlan earned 500 total points
ID: 35010820
I use a method to display folder contents to my users. You will have to clean it up for your use.

Imports SystemIO

 <asp:TreeView ID="tvDirectoryInfo" ExpandDepth="1" runat="server" >
                  </asp:TreeView>
 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Page.IsPostBack = False) Then

           
            Dim RootDir As DirectoryInfo = New DirectoryInfo("\\arctec-web-svr\IntranetFiles\Operations")
           
            Dim dS As New DirectoryStructure
            Dim RootNode As TreeNode = dS.OutputDirectory(RootDir, Nothing, Me.Page)
            ' add the output to the tree
            tvDirectoryInfo.Nodes.Add(RootNode)
        End If
        ' tvDirectoryInfo.ExpandAll()
    End Sub


Here is where the heavy lifting is done **********



Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Web

Public Class DirectoryStructure
    Public Function OutputDirectory(ByVal directory As DirectoryInfo, ByVal parentNode As TreeNode, ByVal callingPage As Page) As TreeNode

        If (directory Is Nothing) Then
            Return Nothing
        End If

        ' create a node for this directory
        'filter for unwanted directories, First directory will always be parent so filter won't stop code
        If Left(directory.Name, 4) = "_vti" Or Right(directory.Name, 5) = "files" Then
            ' do nothing
        Else
            Dim DirNode As TreeNode = New TreeNode(directory.Name)



            ' get subdirectories of the current directory
            Dim SubDirectories() As DirectoryInfo = directory.GetDirectories()
            ' output each subdirectory
            Dim intDirectoryCount As Integer = 0

            'Loop through directories, and subdirectories (looping through OutputDirectory)until there are no more subdirectories
            Do While (intDirectoryCount < SubDirectories.Length)
                OutputDirectory(SubDirectories(intDirectoryCount), DirNode, callingPage)
                intDirectoryCount = (intDirectoryCount + 1)
            Loop
            ' grab and output the current directories files

            Dim Files() As FileInfo = directory.GetFiles()

            Dim FileCount As Integer = 0
            Do While (FileCount < Files.Length)

                Dim strFileName As String = Files(FileCount).Name
                'Filter unwanted file types
                If UCase(Right(strFileName, 4)) = ".PDF" Or UCase(Right(strFileName, 4)) = ".HTM" Or UCase(Right(strFileName, 5)) = ".HTML" Then
                    Then

                                     Dim treeNode As New TreeNode()
                    'get the path of the files directory
                    Dim strFileDir As Object = Files(FileCount).Directory.ToString

                    'Convert string from unc to url
                    strFileDir = Replace(strFileDir, "\", "/")
                                       strFileDir = Replace(strFileDir, "//arctec-web-svr/IntranetFiles", "/IntranetFiles")

                    strFileDir = strFileDir + "/" + strFileName
                    treeNode.NavigateUrl = strFileDir


                    Dim strTreeNodeName As String = Left(strFileName, (Len(strFileName) - 4)) _
                                                   & " (" & (Files(FileCount).Length / 100) & " kb)" _
                                                   & Format((Files(FileCount).LastWriteTime), "  dd MMM, yy")
                    treeNode.Text = strTreeNodeName
                    If Right(strFileName, 4) <> ".htm" Then
                        treeNode.Target = "_blank"
                    End If
                    DirNode.ChildNodes.Add(treeNode)
                End If
                FileCount = (FileCount + 1)

            Loop
            ' if the parent node is null, return this node
            ' otherwise add this node to the parent and return the parent

            If (parentNode Is Nothing) Then
                Return DirNode
            Else
                parentNode.ChildNodes.Add(DirNode)
                Return parentNode
            End If
        End If
        Return New TreeNode()

    End Function


End Class
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question