Web.config配置文件詳解
瀏覽量:3345
花了點時間整理了一下ASP.NET Web.config配置文件的基本使用方法。很適合新手參看,由于Web.config在使用很靈活,可以自定義一些節點。所以這里只介紹一些比較常用的節點。
<?xml version="1.0"?>
<!--注意: 除了手動編輯此文件以外,您還可以使用 Web 管理工具來配置應用程序的設置??梢允褂?nbsp;Visual Studio 中的“網站”->“Asp.Net 配置”選項。
設置和注釋的完整列表在 machine.config.comments 中,該文件通常位于 "Windows"Microsoft.Net"Framework"v2.x"Config 中。-->
<!--Webconfig文件是一個xml文件,configuration是xml文件的根節點,由于xml文件的根節點只能有一個,所以Webconfig的所有配置都是在這個節點內進行的。-->
<configuration>
<!--指定配置節和命名空間聲明。clear:移除對繼承的節和節組的所有引用,只允許由當前 section 和 sectionGroup 元素添加的節和節組。remove:移除對繼承的節和節組的引用。
section:定義配置節處理程序與配置元素之間的關聯。sectionGroup:定義配置節處理程序與配置節之間的關聯。-->
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
<section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<!--appSettings是應用程序設置,可以定義應用程序的全局常量設置等信息-->
<appSettings>
<add key="1" value="1" />
<add key="gao" value="weipeng" />
</appSettings>
<!--連接字符串設置-->
<connectionStrings>
<add name="ConnString" connectionString="Data Source=GAO;Initial Catalog=HBWXDate;User ID=sa;password=sa"></add>
<add name="111" connectionString="11111" />
</connectionStrings>
<!--指定應用子配置設置的資源,并鎖定配置設置,以防止它們被子配置文件重寫。page指定應用包含的配置設置的資源.allowOverride是否允許配置文件的重寫,提高配置文件的安全性-->
<location path="Default.aspx" allowOverride="false">
<!--控制asp.net運行時的行為-->
<system.web>
<!--identity控制web應用程序的身份驗證標識.-->
<identity impersonate="false" />
<!--標識特定于頁的配置設置(如是否啟用會話狀態、視圖狀態,是否檢測用戶的輸入等)