Hi,
The ASP.NET Profile stores more information about logged in user and gives the developer capability of playing with those information later on without coding much.
A great use of Profile is when we would like to store more information about the user in our application. Since ASP.NET membership default implementation provides only basic information about the user like Username, password and Email and there is no chance to add more information like User's First name, Last name, Date of birth, Phone etc.
You can implement adding these information by use of Profile. Very easy just add following code to your Web.Config
(here I am adding name and Age to the user information)
Now you can access these information only by
Profile.Name, Profile.Age
<profile >
<properties>
<add name="Name" allowAnonymous="true" />
<add name="Age" allowAnonymous="true" type="System.Int16"/>
</properties>
</profile>
If you want to save them just set them like,
Profile.Name="interface"
Profile.Age=12
Now, allowAnonymous allows you to access these information when you are anonymous.
Let me clear my words:
Let's consider a scenario that you want to Create a user. You have a form that gets user Name and age and you want to add those information about other information gathered by membership provider to the data store. Since at time creating User you are anonymous to the system Profile.Name and Profile.Age won't be saved. So you must use AllowAnonymous attribute OR use ProfileBase class to set the properties.
System.Web.Profile.ProfileBase pBase = System . Web . Profile . ProfileBase . Create ( userName );
pBase . SetPropertyValue ( "Name" , name );
pBase . SetPropertyValue ( "Age" , age );
pBase . Save ( );