我的 ASP.NET 项目中有一个包含实用程序文件的子目录。代码在运行时需要它们,但我不希望它们在网络上可见。
Web.config 文件中阻止所有用户访问单个子目录及其所有内容的语法是什么?
Mat*_*ttB 16
IIS 7 具有新的“请求过滤”功能。您可能想要使用隐藏段配置:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="BIN"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这会导致http://yoursite/bin不可用(但http://yoursite/binary仍然有效)
查看:http : //learn.iis.net/page.aspx/143/how-to-use-request-filtering