如何隐藏IIS上的文本文件的目录?

我有一个IIS上的文本文件的目录。 我想这个目录是隐藏的。

我已经设置了web.config如下:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <authorization> <deny users="*" /> <!-- Denies all users --> </authorization> </system.web> </configuration> 

但是我仍然可以看到文件的完整目录列表,以及通过networking访问文件。

我设置错了什么?

我也试过这个:

 <system.webServer> <security> <authorization> <remove users="*" roles="" verbs="" /> <add accessType="Allow" roles="Administrators" /> </authorization> </security> </system.webServer> 

但是这也没有帮助我

system.web节点只影响asp.net文件,* .txt文件不受影响。

要隐藏所有用户的文件,在IIS 7.x中有几种方法,这里有两个:

在问题目录内的web.config中:

 <system.webServer> <security> <requestFiltering> <fileExtensions> <add fileExtension=".txt" allowed="false" /> </fileExtensions> </requestFiltering> </security> </system.webServer> 

要么

 <system.webServer> <security> <requestFiltering> <hiddenSegments> <add segment="directoryname" /> </hiddenSegments> </requestFiltering> </security> </system.webServer> 

第一个隐藏所有文本文件,第二个隐藏整个urlpath,都返回404s到用户。

如果你想允许某些用户访问这些文件,这些方法将无法正常工作。 你使用什么样的authentication?