Configuring Virtual Directories with Directory Browsing in IIS7

Thursday, March 20, 2008

A website that uses directory browsing is a convenient way to display the files and folders in a directory using a web browser. An example of this is demonstrated here.

To configure directory browsing in IIS6, you simply enable the Directory Browsing checkbox on Home Directory tab of the virtual directory. If you want to configure it so that users are required to authenticate to access the virtual directory, you disable anonymous access, enable Basic Authentication and configure the appropriate NTFS permissions on the target folder.

It's slightly different in IIS7 since IIS7 introduces the concept of delegated administration. This means that you can have the IIS configuration in web.config files which reside in the virtual directory. IIS has to read these config files very early in the connection attempt, i.e. when there is no authenticated user available yet. For this reason IIS has to use the process identity (usually Network Service) to read the web.config file.

To configure a virtual directory for directory browsing in IIS7:

  • Create or select the virtual directory in Internet Information Services (IIS) Manager
  • Double-click Authentication and select the appropriate authentication methods for the Vdir (default is Anonymous)
  • Select the Vdir again and double-click Directory Browsing. Click the Enable action
  • Right-click the Vdir and select Edit Permissions. Configure the NTFS permissions for the target folder and ensure that Network Service has read access to the folder

If you don't grant the Network Service account read rights on the Vdir, you'll get the following error when accessing it:

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

4 comments:

  1. In order to fix this problem:
    1) At the highest level of the site, click the modules feature

    2) Select FormsAuthentication --> Edit

    3) UN-CHECK "Invoke only for requests to ASP.NET applications or managed handlers"

    4) hit ok


    this worked perfectly for me.

    ReplyDelete
  2. Hi, I can see that the site shown on http://update.nai.com/products/commonupdater/ is not the default directory listing. This directory listing is i.e. showing icons next to the files and directories... Is it possible to have a copy of this cool listing?

    Thanks :o)

    Regards
    Michael Juhl

    ReplyDelete
  3. Having problem on IIS 6 browsing virtual directories after switching from asp.net 2 to 4. Local directories work fine. When I switch back to version 2.0 it works again. Get the following "You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed. HTTP Error 403.1 - Forbidden: Execute access is denied.
    "

    ReplyDelete
  4. This is just a guess (I haven't worked with .NET4 yet), but take a look at the Web Service Extensions at the bottom of the IIS tree. Look to see if the ASP.NET v4 extensions are allowed.

    ReplyDelete

Thank you for your comment! It is my hope that you find the information here useful. Let others know if this post helped you out, or if you have a comment or further information.