IIS在虚拟目录上浏览目录问题

发布于 2024-08-31 20:08:26 字数 190 浏览 6 评论 0原文

我有两个不同的虚拟目录映射到操作系统上的同一目录。在其中一个虚拟目录中,我需要禁用浏览文件夹,在另一个虚拟目录中,我需要启用它。

问题是,当我改变其中一个时,另一个也随之改变。我认为这个问题与两个虚拟目录都指向操作系统中的同一个文件夹有关,但对于 IIS6,我有相同的配置,没有问题。

有解决这个问题的想法吗?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

π浅易 2024-09-07 20:08:26

IIS 7确实使用目录中的web.config文件进行配置,但是,您也可以放弃使用web.config文件(即不使用IIS管理器工具),而不是通过IIS管理器启用目录浏览,只需编辑您的 applicationHost.config 在您真正想要启用浏览的唯一一个虚拟目录上设置目录浏览。这将允许您浏览一个虚拟目录,但不能浏览另一个虚拟目录,即使两者都指向同一物理目录。

这是一个例子:
编辑 applicationHost.config 文件。该文件可以在您的 %WINDIR%\System32\inetsrv\config 目录中找到。

1) 转到文件底部。您应该在其中找到配置部分的 XML 结束标记:

</configuration>

2) 在该标记上方,使用以下内容作为指导添加位置标记:

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

将 {website name} 替换为该网站的网站名称(如 IIS 管理器中所示)问题和{虚拟目录路径}以及您想要浏览的虚拟目录的路径。
示例:

<location path="MyWebsite/imagelist">

现在假设在上面的示例中,imagelist 是一个指向 {your webroot}/pics 的虚拟目录,并且您还有另一个名为 images 的虚拟目录,它也指向{您的网站根目录}/图片。当访问者访问 yoursite.com/images 时,他们将看不到图像列表,但当访问者访问 yoursite.com/imagelist 时,他们将获得返回的目录列表。

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.

薄荷梦 2024-09-07 20:08:26

有很多可能性,但我面临并解决的问题如下。

  1. IIS 中的 .NET 框架与 web.config 中指定的不匹配。将 IIS 中的框架更改为创建的项目之一。 (如果创建的项目或解决方案是 4.5/4.0,则在网站高级设置下将 IIS 更改为 4.0。)

  2. 检查 web.config 中的标记是否为所有节点正确关闭。

这应该有效!

谢谢,
阿南德

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

傲性难收 2024-09-07 20:08:26

之所以与 IIS6 的行为不同,是因为 IIS6 将允许目录浏览的属性存储在 IIS6 元数据库 DirBrowseFlags 虚拟目录的属性,每个虚拟目录都有一个唯一的条目,而在 IIS7 中, 该属性现在仅存储在 Web.config 文件中

<system.webServer>
    <!-- ... -->
    <directoryBrowse enabled="true" />
</system.webServer>

由于 IIS7 中的两个虚拟目录共享相同的物理目录,因此它们都共享相同的 Web.config 文件,因此您会发现更改其中一个的属性会导致更改出现在另一个中,因为它们都修改相同的 Web.config 文件。

(目前我不知道 IIS7 有什么好的解决方法。)

The reason why it is different behavior from IIS6 is that IIS6 stored the property for allowing directory browsing in the IIS6 Metabase DirBrowseFlags property of the virtual directory, which has a unique entry for each virtual directory, whereas in IIS7, that property is now stored only in the Web.config file:

<system.webServer>
    <!-- ... -->
    <directoryBrowse enabled="true" />
</system.webServer>

Since both your virtual directories in IIS7 share the same physical directory, they both share the same Web.config file, and so you'll find that changing the property in one causes the change to appear in the other, as they're both modifying the same Web.config file.

(I don't of know a good workaround to this for IIS7 for you at the moment.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文