A Shopping Cart Example

To see a more comprehensive end-to-end example of profiles, you can refer to the online samples. They include a page named ShoppingCartTest.aspx (in the SqlProfileProviderWindowsAuthentication website), which uses profiles to store a complete shopping cart stocked full of items.

The ShoppingCartTest.aspx example provides a good demonstration of how you can store complex objects in a profile. However, most professional websites won't use profiles in this way, because it forces you to give up too much control over data storage. You're more likely to use session state instead (and possibly use SQL Server-backed session storage if you want partially complete shopping carts to persist between user visits). In fact, the ShoppingCart and ShoppingCartItem classes that the ShoppingCartTest.aspx page uses work equally well if you want to store shopping cart data in session state.

0 0

Post a comment

  • Receive news updates via email from this site