By default profiles enabled only for authenticated users.
Can enable for anonymous users by adding allowAnonymous="true" attribute to the properties, e.g. <add name="LastVisit"allowAnonymous="true" type="System.DateTime />
ASP.NET will create unique identification for each user when first visits site, stored in browser cookies.
If cookies not enabled then identifier added to URL of page request.
Can place properties into groups, can then access through profile class as encapsulated data, e.g. Profile.Address.Street.
<profile>
<properties>
<group name="Address">
<add name="Street" />
<add name="City" />
</group>
</properties>
</profile>
Can use own custom classes as profile properties.
Custom class must be serializable.
<system.web>
<profile>
<properties>
<add name="Pos" type="MyApp.OrgPosition" serializeAs="Binary"/>
</properties>
</profile>
</system.web>
If site implements user authentication then profiles automatically enabled.
If only anonymous users need to add anonymousIdentification to system.web element of web.config. Ensure its enabled attribute is set to true.
If enable anonymous user profiles but allow user to create authentication credentials then ASP.NET will create new profile for user.
May want to migrate settings from their anonymous profile.
Do this by responding to MigrateAnonymous event raised when user logs into site:
public void Profile_OnMigrateAnonymous(object sender ProfileMigrateEventArgs args)
{
ProfileCommon annonProfile = Profile.GetPRofile(args.AnonymousID);
Profile.StockSymbols = annonProfile.StockSymbols;
ProfileManager.DeleteProfile(args.AnonymousID);
SnonymousIdentificationModule.ClearAnonymousIdentifier();
}
Set values of individual Profile properties then call Profile.Save().
Set profile information in response to user actions, e.g. setting their preferred colour.
Mau allow user to set Profile information via a web page.
Profile based on user identification.
If allow anonymous authentication then this is passed as cookie setting.
Otherwise happens at time of user authorisation.
By accessing profile property ASP.NET will perform necessary actions to identify user and lookup value from persistent profile store.