Asp. NET 2.0 Framework provides a method for storing user information: Profile objects that are not used for cookies and session states. Profile provides a strongly-typed and persistent session Status form.
you can create a set of profile attributes in the root web configuration file of the application Program . profile. ASP. NET framework dynamically compiles a class containing these attributes in the background.
</System. Web>
</Configuration>
When defining the profile attribute, you can use the following attributes:
• Name -- specifies the attribute name;
• Type -- specifies the attribute type. The default attribute type is string;
• Defaultvalue -- specify the default attribute value;
• Readonly -- whether the attribute is read-only;
• Serializeas -- used to specify how a property persists as static persistent data;
• Allowanonymous-whether anonymous users are allowed to read and write attributes;
• Provider -- used to associate attributes with a specific profile provider;
• Customproviderdata -- used to pass custom data to the profile provider.
It is important to understand that profile is persistent. If an application sets the profile attribute for a user, the website retains the profile attribute value even if the user has never returned to the website.
The profile object uses the provider model. The default profile provider is sqlprofileprovider. by default, the provider saves profile data to the name aspnetdb. in the SQL Server 2005 express database of MDF, the database is saved in the app_code folder of the application. If the database does not exist, it is automatically created when the profile object is used for the first time.
Create a user configuration file group
If you need to define many profile attributes, it is easier to divide these profile attributes into groups for management, as shown below:
<? XML version = "1.0"?>
<Configuration>
<System. Web>
<Profile>
<Properties>
<Group name = "Preferences">
<Add name = "backcolor" defaultvalue = "lightblue"/>
<Add name = "font" defaultvalue = "Arial"/>
</Group>
<Group name = "contactinfo">
<Add name = "email" defaultvalue = "your email"/>
<Add name = "phone" defaultvalue = "your phone"/>
</Group>
</Properties>
</Profile>
</System. Web>
</Configuration>
InCodeUsed in:
Lblemail. Text = profile. contactinfo. Email;
Lblphone. Text = profile. contactinfo. Phone;