ASP.NET中的应用程序配置(1)

1、两种配置文件基本信息
machine.config--计算机基本配置文件
配置文件路径为:
XP下为:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config"
NT下为:"C:\WinNT\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config"
Web.config--程序配置文件
该配置放于wwwroot根目录、应用程序根目录、子目录下。

2.1、Web.config基本结构
        Web.config文件的配置分为两个部分:配置节处理程序声明部分配置节设置部分。这两部分都位于配置文件的跟标记<configuration>...</configuration>之间。配置节处理程序声明部分一般位于配置文件顶部的<configSections>...</configSections>标记之间。每个声明都包含在一个<section>标记中,它们被用来指定特定配置数据集的节的名称和处理该节中配置数据的.NET框架类的名称。配置节设置部分一般位于</configuration>标记之后。<system.Web>和<appSetting>都属于具体的配置节设置部分。
         下面的代码给出配置的基本结构:
         

<configuration>
<configSections>
<section name="appSettings" type=""/>
<section name="sessionState" type=""/>
</configSections>

<appSettings>
<add key="dns" value="localhost;uid=zhh;pwd=;"/>
</appSettings>
<system.Web>

<sessionState />

</system.Web>
</configuration>

2.2、配置节组
         在ASP.NET中可以用<sectionGroup>标记来对定义好的节进行分组。<sectionGroup>可以出现在<configSections>标记的内部或其他<sectionGroup>标记的内部。也就是说,<sectionGroup>标记可以进行嵌套。下面给出配置节组的示例:
         

<configuration>
<configSections>
<sectionGroup name="system.net">
<section name="authenticationModules" type=""/>
<section name="WebRequestModules" type=""/>
</sectionGroup>

<sectionGroup name="system.Web">
<section name="authorization" type=""/>
<section name="sessionState" type=""/>
</sectionGroup>
</configSections>

<system.net>
<!--Net Class Settings would go here.-->
</system.net>

<system.Web>
<authorization>

</authorization>
<sessionState />
</system.Web>
</configuration>


注:具体配置节下回在摘录

posted @ 2005-06-22 21:05  zhh007's Bolg  阅读(350)  评论(0编辑  收藏  举报