配置文件记录(1)

1、配置文件的继承性:
每一个web.config文件都会将其配置设置应用于本身所在的目录及其下的所有子目录。
子目录的web.config文件继承父目录的配置设置
子目录的配置文件设置会重写或修改父目录中相同的配置设置。
2、配置文件的格式
<?xml version="1.0' encoding="utf-8"?>
<configuration>
     <system.web>
        <compilation defaultLanguage="vb" debug="true"/>
        <customErrors mode="RomoteOnly"/>
        <authentication>
            <allow users="*"/>
        </authentication>
    </system.web>
</configuration>
3、配置文件的结构
(1)<configSections>配置段
用于指定<configSection>处理程序,后者是一个函数,用于解释web.config配置文件中的XML,并将信息返回给的用户。
该配置段在需要添加自定义配置文件处理程序时使用。语法如下:
<?xml version="1.0" encoding="jtf-8"?>
<configuration>
    <section name="[SectionSettings]" type="[Class]"/>
    <sectionGroup name="[SectionGroup]">
            <section name="[SectionSettings"] type="[Class]"/>
     </sectionGroup>
</configuration>
(2)<appSection>配置段
<appSection>配置段用于存储自定义的系统级应用程序设置,这些设置将返回一个基于字符串的值。以下是一个<appSection>配置段的范例。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appSections>
        <add key="appName" value="ProjectName"/>
        <add key="appAuthor" value="Jakie W"/>
    </appSections>
</configuration>
(3) <system.web>
通过该配置段可以控制asp.net应用程序的行为模式。
(4) <location> 锁定配置设置
通常情况下,子目录的配置设置为重写父目录的配置文件同的配置设置,如果希望较高层次中的某元素的配置设置不被较低层次目录的配置文件所重写或更改,只需将该配置设置包含与<location>与</location>标记中,并在<location> 中加入allowOverride="false" 的属性设置以便锁定该配置设置。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="file" allowOverride="false">
    <system.web>
        <compilation defaultLanguage="vb" debug="true"/>
        <customErrors mode="RomoteOnly"/>
        <authentication>
            <allow users="*"/>
        </authentication>
    </system.web>
</location>
</configuration>



posted @ 2006-03-12 18:52  叶晓丰  阅读(210)  评论(0编辑  收藏  举报