It is used to store user-related data and maintain the application status. The profile object provides a method for creating session States with strong and persistent modes.
Use profile. shoppingcart. Add ();
Profile. Save ();
For example
The configuration file code is as follows:
Code
<Profile automaticsaveenabled = "false" defaultprovider = "shoppingcartprovider">
<Providers>
<Add name = "shoppingcartprovider" connectionstringname = "sqlprofileconn" type = "petshop. profile. petshopprofileprovider" applicationname = ". Net Pet Shop 4.0"/>
</Providers>
<Properties>
<Add name = "shoppingcart" type = "petshop. BLL. Cart" allowanonymous = "true" provider = "shoppingcartprovider"/>
</Properties>
</Profile>
According to the configuration file, the property that needs to be stored is petshop. BLL. cart, and the Custom User Configuration provider is shoppingcartprovider, which stores related information in the petshop. BLL. Cart class. Because shoppingcartprovider is a Custom User Configuration provider, it must inherit from system. web. profile. profileprovider, override some methods in the parent class, such as initialize (), getpropertyvalues (), setpropertyvalues (), and so on.
Start the web application. ASP. NET creates an instance of the profilecommon Class Based on the configuration file. This class inherits from the system. Web. profile. profilebase class. According to some code of the profilecommon class
Code
Public Virtual petshop. BLL. Cart shoppingcart {
Get {
Return (petshop. BLL. Cart) (This. getpropertyvalue ("shoppingcart ")));
}
Set {
This. setpropertyvalue ("shoppingcart", value );
}
}
Call the override initialize () method to set the options and initial values of the provider instance. Then. getproertyvalue ("shoppingcart"), call the getpropertyvalues method to obtain the relevant property type petshop. bll. after the information in the cart (stored in the database), perform a forced conversion (petshop. bll. cart) (this. getproertyvalue ("shoppingcart"), and then calls cart. add () method.
After the profile. Save () method is called, the program calls the repeated method setpropertyvalue () in shoppingcartprovider to save related information in petshop. BLL. Cart.
Go to: http://www.cnblogs.com/sunny0311/archive/2008/09/22/1296241.html