本文介绍了我可以使用通配符在web.config中的位置路径属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在IIS 7我试图拒绝访问所有文件扩展名的.xml的所有用户。
In IIS 7 I try to deny access to all files with the extension .xml for all users.
我尝试以下设置在我的web.config文件:
I tried the following setting in my web.config file:
<location path="*.xml">
<system.web>
<authorization>
<deny users="*"/>
</authorization>
</system.web>
</location>
但后来得到任何文件会导致内部服务器错误。
But then getting any file results in an internal server error.
它的工作原理,如果我拒绝访问单个文件,但这种解决方案并不买我就像我不知道事先的所有.xml文件。
It works if I deny access to the individual files but this solution does not buy me much as I do not know all .xml files in advance.
推荐答案
试试这个:
<configuration>
<system.web>
<httpHandlers>
<add path="*.xml" verb="*"
type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
</system.web>
</configuration>
这是你可以或者所有的XML文件的存储在App_Data目录。任何类型的此目录中的文件存储将不会投放到网上。
By the way you could alternatively store all of your xml files within the App_Data directory. Storing files of any type in this directory will not be served to the web.
这篇关于我可以使用通配符在web.config中的位置路径属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!