Profile 讓開發者以聲明式方式定義使用者屬性,自動持久化至資料庫,支援匿名使用者設定並在登入後無縫遷移。
<profile enabled="true" defaultProvider="SqlProfileProvider" inherits="CustomProfile">
<providers>
<add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlConnectionString" applicationName="/" />
</providers>
<properties>
<add name="Name" />
<add name="Color" type="System.Drawing.Color" />
<group name="Group">
<add name="Collection" type="System.Collections.ArrayList" />
<add name="Price" type="int" defaultValue="100" />
</group>
</properties>
</profile>
<anonymousIdentification enabled="true" cookieName=".VS2005_ANONYMOUS"
cookieTimeout="1440" cookiePath="/" cookieRequireSSL="false"
cookieSlidingExpiration="true" cookieProtection="All" cookieless="UseCookies" />
inherits="CustomProfile":繼承自訂 ProfileBase 子類別,獲得強型別存取(Profile.Name vs Profile.GetPropertyValue("Name"))。<group>)邏輯分組,存取時 Profile.Group.Price。Profile.MigrateAnonymous(oldAnonId) 合併資料。屬性詳細說明請參閱 MSDN「profile 元素」與「anonymousIdentification 元素」。