我们在开发电子商务网站时,经常会遇到这样一个问题,那就是当用户在网站身份验证前选好商品放入购物车后,然后再登录并通过了身份验证,奇怪的是前面购物车选好的商品没了,要解决这个问题其实蛮简单的,就是在Global.asax里注册一个MigrateAnonymous事件,如此一来,数据就不会丢失了。 C#示例代码:<激光传真机> public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args) { // Get anonymous profile ProfileCommon anonProfile = Profile.GetProfile(args.AnonymousID); // Copy anonymous properties to authenticated foreach (SettingsProperty prop in ProfileBase.Properties) Profile[prop.Name] = anonProfile[prop.Name]; // Kill the anonymous profile ProfileManager.DeleteProfile(args.AnonymousID); AnonymousIdentificationModule.ClearAnonymousIdentifier(); } 推荐链接:黑白激光一体机