ASPX to List Folders

Posted on 2014-03-06 in

Problem: A folder with a bunch of hidden subfolders on an IIS web server. Directory index pages (generated pages listing the contents of the folder) are disabled for security reasons. This file is dropped in with an obscure file name so that those who know it can browse the list.


<%@ Page Language="c#"%>
<%@ Import Namespace="System.IO" %>

<h1>These are the folders.</h1>

    <% var root = Request.PhysicalApplicationPath; %>
    <% foreach (var dir in new DirectoryInfo(root).GetDirectories()) { %>
        <li><a href="./<%= dir.Name %>"><%= dir.Name %></li>
    <% } %>


Leave a Comment:

Blog Search

Some Tags

Programming Is Fun

This is a blog about programming for the sheer joy of it. More...