概念
配置文件是以纯文本格式存储的,使用XML编写
特点
如果对文件进行了修改,无需重新启动服务器
每个目录可以有自己的文件,并且将重写先前的配置文件
类型
1、Machine.Config
驻留在服务器上的所有应用程序
每台计算机仅可以有一个Machine.Config文件
2、Web.Config
驻留在服务器上的单个应用程序
Web应用程序的每个目录仅可以有一个此文件
Web.Config重写Machine.Config
Web.Config
页配置设置
<configuration>
//可以缓冲对客户端的响应
<System.web>
<pages buffer="true"
//可以设置视图状态
enableViewState="false"/>
</System.web>
</configuration>
应用程序设置
//配置文件中
<configuration>
//键值对形式的配置设置
<appSettings>
<add key="MySQLQuery" value="Select * From MySQLTable"/>
</appSettings>
</configuration>
//ASP.NET中
String GetQuery=Configuration.AppSettings("MySQLQuery");
customErrors设置
<configuration>
<System.web>
<customErrors
defaultRedirect="url"
mode="On|Off|RemoteOnly">
<error statusCode="statuscode" redirect="url"/>
</customErrors>
</System.web>
</configuration>
验证与授权
身份验证类型 | 描述 |
---|---|
Windows | 默认的身份验证形式,用于任何形式的IIS身份验证 |
Forms | 基于ASP.NET窗体的身份验证作为默认的身份验证模式 |
Passport | Microsoft Passport身份验证作为默认的身份验证模式 |
None | 没有身份验证。用户匿名用户和可以提供其自己的身份验证的应用程序 |
<configuration>
<System.web>
<authentication mode="Windows|Forms|Passport|None">
<forms name="name" loginUrl="url"
protection="All|None|Encryption"
timeout="XX" path="/">
<credentials passwordFormat="Clear|SHA1|MD5">
<user name="用户名" password="密码"/>
</credentials>
</forms>
<passport rediretUrl="intermal"/>
</authentication>
</System.web>
</configuration>
forms标记的属性