Share via


DirectoryBrowseSection Class [IIS 7 and higher]

Configures directory browsing in IIS.

Syntax

class DirectoryBrowseSection : ConfigurationSection

Methods

The following table lists the methods exposed by the DirectoryBrowseSection class.

Name

Description

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

Properties

The following table lists the properties exposed by the DirectoryBrowseSection class.

Name

Description

Enabled

A read/write boolean value. true if directory browsing will be enabled for a directory in IIS; otherwise, false. The default is false.

Location

(Inherited from ConfigurationSection.) A key property.

Path

(Inherited from ConfigurationSection.) A key property.

SectionInformation

(Inherited from ConfigurationSection.)

ShowFlags

A sint32 value containing a mask that configures the display of file information in a browsed directory. The possible values are listed later in the Remarks section.

Subclasses

This class contains no subclasses.

Remarks

If directory browsing is enabled for a directory in IIS, users receive a page that lists the contents of the directory when the following are true:

  • The user does not specify a file in the URL (for example, the user goes to https://www.contoso.com/ instead of https://www.contoso.com/default.htm).

  • Default documents are disabled in IIS, or IIS is unable to locate a file in the directory that matches a name specified in the IIS default document list.

Note

By default, directory browsing is disabled in IIS so that users cannot see the contents of directories. To enhance security, you should leave directory browsing disabled unless you have a specific reason to enable it—for example, to share files over HTTP using Web Distributed Authoring and Versioning (WebDAV). If you enable directory browsing, ensure that you enable it only on the particular directory or directories that you want to share.

The following table lists the possible values for the ShowFlags property. The default values are 2 (Date), 4 (Time), 8 (Size), and 16 (Extension).

Value

Keyword

Description

0

None

Displays file names without extensions. This flag has no effect when other flags are already specified.

2

Date

The last modified date for each file.

4

Time

The last modified time for each file.

8

Size

The size of each file.

16

Extension

The file extension after the file name.

32

LongDate

The last modified date in extended format for each file.

Example

The following example displays the properties of the DirectoryBrowseSection class for the default Web site.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = _
    GetObject("winmgmts:root\WebAdministration")
Set oService = GetObject("winmgmts:root\WebAdministration")

' Get the directory browse section of the default Web site.
Set oSite = oService.Get("Site.Name='Default Web Site'")
oSite.GetSection "DirectoryBrowseSection", oSection


' Display the properties.
WScript.Echo "DirectoryBrowseSection Properties"
WScript.Echo "---------------------------------"
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location
WScript.Echo "Enabled: " & oSection.Enabled
WScript.Echo "ShowFlags: " & oSection.ShowFlags
WScript.Echo 
WScript.Echo "DirectoryBrowseSection.SectionInformation"
WScript.Echo "-----------------------------------------"
WScript.Echo "OverrideMode: " & oSection.SectionInformation.OverrideMode
WScript.Echo "EffectiveOverrideMode: " & oSection.SectionInformation.EffectiveOverrideMode
WScript.Echo "IsLocked: " & _
    oSection.SectionInformation.IsLocked
WScript.Echo "LockItem: " & _
    oSection.SectionInformation.LockItem

Inheritance Hierarchy

ConfigurationSection

   DirectoryBrowseSection

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

ConfigurationSection Class [IIS 7 and higher]

Other Resources

Configure Directory Browsing