我的ASP.Net应用程序包含一个子目录 foo ,不应使用http访问。我认为最简单的解决方案是将web.config放在子目录 foo 中。
<configuration>
<system.web>
<httpRuntime enable="false"/>
</system.web>
</configuration>
但它不起作用。例如,服务器不会拒绝http://myapp/foo/test.html
。
答案 0 :(得分:1)
您可以尝试在web.config中添加:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="directoryYouWantToProtect"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
我测试了它似乎工作正常,当我尝试列出目录或直接访问文件时我有404.8 HTTP错误(请求过滤模块配置为拒绝包含hiddenSegment部分的URL中的路径)