Asp.net 完全阻止http访问应用程序子目录的最简单方法是什么?
我的ASP.Net应用程序包含一个子目录foo,不应使用http访问该子目录。我认为最简单的解决方案是将下面的web.config放在foo子目录中Asp.net 完全阻止http访问应用程序子目录的最简单方法是什么?,asp.net,web-config,virtual-directory,Asp.net,Web Config,Virtual Directory,我的ASP.Net应用程序包含一个子目录foo,不应使用http访问该子目录。我认为最简单的解决方案是将下面的web.config放在foo子目录中 但它不起作用。例如,http://myapp/foo/test.html未被服务器拒绝。您可以尝试在web.config中添加此选项: <configuration> <system.webServer> <security> <requestFiltering> <hi
但它不起作用。例如,
http://myapp/foo/test.html
未被服务器拒绝。您可以尝试在web.config中添加此选项:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="directoryYouWantToProtect"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
我对它进行了测试,它似乎工作得很好,当我试图列出目录或直接访问文件时,我出现了404.8 HTTP错误(请求过滤模块被配置为拒绝URL中包含HiddenSem分段的路径)
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="directoryYouWantToProtect"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>