拒绝访问 ASP.NET 中的文件夹

发布于 2024-08-06 01:33:23 字数 98 浏览 2 评论 0原文

除了创建默认页面(例如使用 web.config)之外,是否可以阻止浏览 ASP.NET Web 应用程序中的文件夹内容? 如果可能的话,我想避免使用 IIS。

谢谢

is it possible to prevent browsing of a folder contents in an ASP.NET web application other than creating a default page, say using web.config?
I would like to avoid using IIS for this if possible.

Thanks

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

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

发布评论

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

评论(2

以酷 2024-08-13 01:33:23

如果您使用的是 IIS7,则可以使用 web.config 文件来实现此目的。为所需文件夹指定 标记,并为其指定 子标记,即:

<location path="path to your folder">
  <system.webServer>
    <directoryBrowse enabled="false" />
  </system.webServer>
</location>

If you are using IIS7, you can use web.config files for this. Specify a <location> tag for the desired folder, and give it a <directoryBrowse> sub-tag, ie:

<location path="path to your folder">
  <system.webServer>
    <directoryBrowse enabled="false" />
  </system.webServer>
</location>
手心的海 2024-08-13 01:33:23

之前的回答system.webServer -> DirectoryBrowse 是新的,只能在您的站点在 IIS7 下运行时使用(无论是调试还是其他),它在 IIS6 中不起作用。在 IIS6 中,您需要使用 IIS 管理控制台来执行此操作。

The previous answer system.webServer -> directoryBrowse is new and can be used when your site is running under IIS7 (be it debugging or otherwise) only, it will not work in IIS6. In IIS6 you need to do it using the IIS management console.

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