profile 項目 (ASP.NET 設定結構描述)
設定參數,以使用 ASP.NET 設定檔管理使用者設定檔值。
這個項目是 .NET Framework 2.0 版中新增的項目。
<profile
enabled="true|false"
inherits="fully qualified type reference"
automaticSaveEnabled="true|false"
defaultProvider="provider name">
<properties>...</properties>
<providers>...</providers>
</profile>
屬性和項目
下列各節將說明屬性、子項目和父項目。
屬性
屬性 |
說明 |
---|---|
enabled |
選擇性 Boolean 屬性。 指定 ASP.NET 使用者設定檔是否已啟用。 如果為 true,則 ASP.NET 使用者設定檔已啟用。 預設值為 true。 |
defaultProvider |
選擇性 String 屬性。 指定預設設定檔提供者的名稱。 如需詳細資訊,請參閱 Provider。 預設值為 AspNetSqlProfileProvider。 |
inherits |
選擇性 String 屬性。 包含衍生自 ProfileBase 抽象類別之自訂型別的型別參考。 ASP.NET 會動態產生繼承自這個型別的 ProfileCommon 類別,並將其置於目前 HttpContext 的 Profile 屬性。 |
automaticSaveEnabled |
選擇性 Boolean 屬性。 指定使用者設定檔在 ASP.NET Web 網頁執行結束時是否會自動儲存。 如果為 true,則使用者設定檔在 ASP.NET Web 網頁執行結束時會自動儲存。 只有在模組偵測到設定檔已修改時,ProfileModule 物件才會儲存使用者設定檔。 也就是 IsDirty 屬性為 true 時。 如需詳細資訊,請參閱ASP.NET 設定檔屬性概觀。 預設值為 true。 |
子項目
項目 |
描述 |
---|---|
properties |
必要項目。 定義使用者設定檔屬性和屬性群組的集合。 |
providers |
選擇性項目。 定義設定檔提供者的集合。 |
父項目
項目 |
說明 |
---|---|
configuration |
指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中需要的根項目 (Root Element)。 |
system.web |
指定 ASP.NET 組態區段的根項目。 |
備註
如需存取和修改應用程式程式碼中 profile 項目組態值的詳細資訊,請參閱 ProfileSection。
預設組態
下列預設 profile 項目是在 .NET Framework 2.0 版中的 Machine.config 檔案中設定。
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</profile>
範例
下列程式碼範例將顯示如何將 ASP.NET 應用程式的 Web.config 檔案設定為使用 SqlProfileProvider 提供者。
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial
Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<authentication mode="Forms" >
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
applicationName="SampleApplication"
enablePasswordRetrieval="true"
enablePasswordReset="true"
passwordFormat="Encrypted"
requiresQuestionAndAnswer="true" />
</providers>
</membership>
<profile defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
applicationName="SampleApplication"
description="SqlProfileProvider for SampleApplication" />
</providers>
<properties>
<add name="ZipCode" />
<add name="CityAndState" />
</properties>
</profile>
</system.web>
</configuration>
項目資訊
組態區段處理常式 |
|
組態成員 |
|
可設定的位置 |
Machine.config 根層次的 Web.config 應用程式層級的 Web.config |
需求 |
Microsoft Internet Information Services (IIS) 5.0、5.1 或 6.0 版 .NET Framework 2.0 版 Microsoft Visual Studio 2005 |
請參閱
工作
參考
system.web 項目 (ASP.NET 設定結構描述)
設定檔的 properties 項目 (ASP.NET 設定結構描述)
設定檔的 providers 項目 (ASP.NET 設定結構描述)