When an anonymous user is authenticated, you need to manually migrate his profile properties.
Although ASP.NET 2.0 lets you maintain information for both authenticated and anonymous users, you need to take special steps to preserve data when you authenticate an anonymous user. For example, an anonymous user may already have items in her shopping cart when she logs in. In this situation, profile data that was saved while she was an anonymous user would normally be lost when the user switches from using a GUID to using a user ID for identification. To migrate the profile of the user, you need to transfer whatever information has been saved as an anonymous profile to the user profile.
In this lab, you will build on the previous lab, Section 7.3, and learn how you can migrate an anonymous profile to an authenticated profile once a user has been authenticated.
Using the project created in the last lab (C:\ASPNET20\chap07-Profile), add a new Web Form to the Members folder. Name the Web Form Checkout.aspx.
Add a Global.asax file to the project (right-click the project name in Solution Explorer and then select Add New Item...; select Global Application Class).
The Solution Explorer should now look like Figure 7-15.
Figure 7-16. Adding the Global.asax file to the project
Add the following method to Global.asax. The ...