Profile:字典上解释是:个性的简要描述。在这里就是指网站访问者的个性化信息。
传统的保存个性化信息方式有Cookie,Session,
Cookie 将数据存在客户端浏览器上,并且只能保存少量的字符信息,最多支持3K,安全性也差;
Session将数据一段时间存在服务器端,当访问量大的时候,会占用相当的服务器资源,当访问者关闭浏览器重新访问或者相当一段时间不操作后,
Session信息将会丢失。
Profile 是微软提供的另一种解决保存用户访问信息的方案,它支持持久化保存,即时用户隔离很长时间,再来访问网站,也能再次得到与该用户相关的个性化信息。
代码
<configuration>
<connectionStrings>
<add name="aspnetdb"
<connectionStrings>
<add name="aspnetdb"
connectionString="Data Source=WWW-GAZBM8N3Y7U\;Initial Catalog=aspnetdb;User ID=sa;Password=sa"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authentication mode="Forms"/>
<anonymousIdentification enabled="true"/>
<profile defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider"
type="System.WEB.Profile.SqlProfileProvider"
connectionStringName="aspnetdb"
applicationName="ProfileSample"
description="Sample fro asp.net profile and profile service."/>
</providers>
<properties>
<add name="PageVisitors" type="Int32" allowAnonymous="true"/>
<group name="Name">
<add name="FirstName" type="String" allowAnonymous="true"/>
<add name="LastName" type="String" allowAnonymous="true"/>
</group>
</properties>
</profile>
</system.web>
</configuration>
</connectionStrings>
<system.web>
<authentication mode="Forms"/>
<anonymousIdentification enabled="true"/>
<profile defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider"
type="System.WEB.Profile.SqlProfileProvider"
connectionStringName="aspnetdb"
applicationName="ProfileSample"
description="Sample fro asp.net profile and profile service."/>
</providers>
<properties>
<add name="PageVisitors" type="Int32" allowAnonymous="true"/>
<group name="Name">
<add name="FirstName" type="String" allowAnonymous="true"/>
<add name="LastName" type="String" allowAnonymous="true"/>
</group>
</properties>
</profile>
</system.web>
</configuration>