How to Enable and Configure Directory Browsing in IIS 7 for Static HTML Sites


2 views

When working with static HTML sites on IIS 7, you might find that the Directory Browsing feature isn't visible in the IIS Manager interface, even though Microsoft's documentation suggests it should be available. This typically occurs because the feature isn't installed by default in some IIS 7 configurations.

Before you can enable directory browsing, you need to ensure the feature is actually installed:

1. Open "Turn Windows features on or off" (Start > Control Panel > Programs > Turn Windows features on or off)
2. Navigate to: Internet Information Services > World Wide Web Services > Common HTTP Features
3. Check "Directory Browsing"
4. Click OK and wait for installation to complete

Once installed, follow these steps:

1. Open IIS Manager (inetmgr)
2. Select your website in the Connections pane
3. Double-click the "Directory Browsing" icon in Features View
4. In the Actions pane, click "Enable"
5. Configure which file information to display:
   - Time
   - Size
   - Extension
   - Date
6. Click "Apply" in the Actions pane

Even for static sites, you can use a web.config file to control directory browsing:

<configuration>
  <system.webServer>
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

Before enabling directory browsing, consider these security implications:

  • Exposes your directory structure to visitors
  • May reveal sensitive files if not properly configured
  • Should be limited to specific directories when possible

To restrict directory browsing to specific folders:

<location path="PublicFiles">
  <system.webServer>
    <directoryBrowse enabled="true" />
  </system.webServer>
</location>

If directory browsing still doesn't work after enabling:

  • Check that "Default Document" feature isn't overriding it
  • Verify the IUSR account has proper permissions
  • Clear your browser cache and try a different client
  • Check for parent directory configurations that might override settings

While Microsoft's documentation clearly states that directory browsing can be enabled through IIS Manager, many administrators encounter a frustrating situation where the "Directory Browsing" option simply doesn't appear in their Features View. This typically happens when the required IIS component isn't installed.

Before you can enable directory browsing, you need to ensure the feature is actually installed on your server. Here's how to check and install it:

# PowerShell command to install Directory Browsing feature
Add-WindowsFeature Web-Dir-Browsing

For Windows Server 2008/2012 using Server Manager:

  1. Open Server Manager
  2. Navigate to Roles → Web Server (IIS)
  3. Click "Add Role Services"
  4. Check "Directory Browsing" under Common HTTP Features
  5. Complete the installation wizard

Once the component is installed, you'll find the Directory Browsing option in IIS Manager:

1. Open IIS Manager
2. Select your website or server node
3. Double-click "Directory Browsing" in Features View
4. Click "Enable" in the Actions pane

If you prefer command-line configuration or need to automate the process:

Using AppCmd

%windir%\system32\inetsrv\appcmd set config "Default Web Site" 
-section:system.webServer/directoryBrowse /enabled:"True" /commit:apphost

Direct web.config Modification

Add this to your web.config file:

<configuration>
  <system.webServer>
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

You can control what information appears in the directory listing:

<directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />

Available flags: Date, Time, Size, Extension, LongDate

If directory browsing still doesn't work after enabling:

  • Verify NTFS permissions on the directory (IIS_IUSRS needs Read access)
  • Check if a parent directory has directoryBrowse disabled
  • Ensure no URL rewrite rules are interfering
  • Clear configuration cache with: iisreset /noforce