IIS browse directory problem on a virtual directory

18,340

Solution 1

IIS 7 does indeed use the web.config file in directories for configuration, however, you can also forego using the web.config file (i.e. do not use the IIS Manager tool) and instead of enabling directory browsing through the IIS Manager, simply edit your applicationHost.config to setup directory browsing on the one and only virtual directory you actually want the browsing enabled. This will allow you to have browsing in one virtual directory but not another even when both point to the same physical directory.

Here's an example: Edit the applicationHost.config file. This file can be found in your %WINDIR%\System32\inetsrv\config directory.

1) Go to the bottom of the file. You should find an XML closing tag there for the configuration section:

</configuration>

2) above that tag, add a location tag using the following as a guide:

 <location path="{website name}/{path to virtual directory}">
      <system.webServer>
           <directoryBrowse enabled="true" />
      </system.webServer>
 </location>

Replace {website name} with the website name (as seen in IIS Manager) for the website in question and {path to virtual directory} with the path to the virtual directory you want browsing to be available. Example:

<location path="MyWebsite/imagelist">

Now let's say in the above example, imagelist is a virtual directory that points to {your webroot}/pics and you have another virtual directory called images that also points to {your webroot}/pics. When a visitor goes to yoursite.com/images they will not see the image list, but when they go to yoursite.com/imagelist they will get a directory listing returned.

Solution 2

There are many possibilities, but what I faced and fixed it is as below.

  1. .NET framework in IIS not matching with the one specified in web.config. Change the framework in IIS to the one of which project created. (if project or solution created is 4.5/4.0 then change in IIS to 4.0 under your website advance settings.)

  2. Check for the tags in web.config closed properly for all the nodes.

This should work!!

Thanks, Anand

Share:
18,340
user335518
Author by

user335518

Updated on June 04, 2022

Comments

  • user335518
    user335518 almost 2 years

    I have two differents virtual directories mapping to the same directory on the OS. In one of this virtual directories I need to have the browse folders disable, and in the other one I need to have it enable.

    The problem is that when I changed one of them the other change as well. I thinks this problem is related that both virtual directories points to the same folder in the OS, but with the IIS6 I had this same configuration with out a problem.

    Any idea of a work around with this?

    Thanks!

  • user335518
    user335518 about 14 years
    Thanks Mike for the explanation, I am also still looking but without luck.
  • Mike Atlas
    Mike Atlas about 14 years
    You're welcome. Here's some points so you can now upvote answers =)