元素
指定需要应用特定的配置设置的资源。
配置结构的示例:
path="path"
allowoverride="true|false" />
可选属性
属性 | 选项 | 描述 |
---|---|---|
path | 需要应用特定的配置设置的资源。如果使用 时未指定路径属性,那么配置设置将应用于当前目录和所有的子目录。如果使用 时未指定 path 属性,且将 allowOverride 指定为 false,那么子目录中的 Web.config 文件将不能更改配置设置。 | |
allowOverride | 指定配置设置是否可以由子目录中的 Web.config 文件覆盖。 | |
true | 指定可以覆盖配置设置。默认值是 true。 | |
false | 指定不能覆盖配置设置。 |
示例
下例允许匿名用户访问 Logon.aspx 页。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location path ="Logon.aspx" >
< system.web >
< authorization >
< allow users ="?" />
authorization >
system.web >
location >
configuration >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location path ="Logon.aspx" >
< system.web >
< authorization >
< allow users ="?" />
authorization >
system.web >
location >
configuration >
下例只将指定页面的上载文件大小限制设置为 128KB。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location path ="UploadPage.aspx" >
< httpRuntime maxRequestLength ="128" />
location >
configuration >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location path ="UploadPage.aspx" >
< httpRuntime maxRequestLength ="128" />
location >
configuration >
下例不允许子目录中的 Web.config 文件更改配置设置。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location allowOverride ="false" />
configuration >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < configuration >
< location allowOverride ="false" />
configuration >
要求
- Web 平台:IIS 5.0、IIS 5.1、IIS 6.0
- 配置文件:Machine.config、Web.config
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-617608/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12639172/viewspace-617608/