ASP. NET 2.0 secrets Reading Notes 7-use the user profile

Source: Internet
Author: User

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>
   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"?>
<System. Web>

<Group name = "Preferences">
<Add name = "backcolor" defaultvalue = "lightblue"/>
<Add name = "font" defaultvalue = "Arial"/>
<Group name = "contactinfo">
<Add name = "email" defaultvalue = "your email"/>
<Add name = "phone" defaultvalue = "your phone"/>

</System. Web>
InCodeUsed in:
Lblemail. Text = profile. contactinfo. Email;
Lblphone. Text = profile. contactinfo. Phone;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.