ASP.Net Profile Propety

A website when provides the user to customise the look and feel according to their preferences with their personal touch, it is much liked.
Using profile properties is the best way to provide this functionality along with an important aspect of recognising the user and their preferences and present them with their custom layout.

To implement user profiles we need to follow the following steps
1. Specify where the user profile will be saved. this is done by specifying the Profile Provider.
2. After configuring the profile provider, we have to decide what information we need to save for the user for example  define the user profile.
3. After this we establish a mechanism to identify the user in a unique way, because not all of the visitors of the website will be members.
4. After indentifying the users uniquely we will notice his preferences and store them in profile provider.
The default settings of profile only authenticates the user who are memebers and regularly visiting the website but we have to configure it for anonymous users or guest visitors.
The profile provider specifies the store where the user preferences are stored. Typically this is database. This needs to be done in the web.config file.
Following is an example
<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>
The configuration shows the default profile provider which is local database placed in the App_Data directory of the website. If we need to specify the custom profile provider then we need to specify the connectionString intead of connectionStringName to use the desired database.
Also, we will be needing to set the database to accept and save the profile related data. this is done by running the aspnet_regsql command against the database which will to be used to save the profile data.
After configuring the profile provider, we have to specify the user data that we need to save. We do this by having the properties in the provider element of web.config.
Following is an example
<profile>
<properties>
<add name="Name" allowAnonymous="true"/>
<add name="VisitedOn" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>
The allowAnonymous="true" specifies that the anonymous users will be able to save their profile information. To work this properly we need to specify <anonymousIdentification enabled="true"/> in the web.config file.
After completing this successfully we are able to save all properties we need to track as the user profile information and it works for authenticated as well as anonymous users.
Following is an example of accessing the profile property
string name = Profile.Name;         
DateTime lastVisited = Profile.VisitedOn;
Following is an example of setting the profile property
Profile.Name = TextBox1.Text;
Profile.VisitedOn = DateTime.Now;
Profile.Save();
Profile functionality differs from cokkies in a way that if the user deletes the cookies then the info stored in cookie will be lost.

For further question please mail: brainstormiert@gmail.com