现在的位置: 首页 > 综合 > 正文

关于Profile shopping with anno…超强的!

2012年03月26日 ⁄ 综合 ⁄ 共 1319字 ⁄ 字号 评论关闭

Profile对象既可用于匿名用户也可以用于已认证用户。然而,当用户从匿名用户状态转换为已认证用户状态时,Profile对象能够以一种令人难以理解的方式完成任务。  
  当匿名用户使用Profile对象时,用户profile是与一个随机生成的号码相关联的,该号码是根据每个用户唯一生成的,它保存在浏览器的cookie中,无论何时该用户返回应用程序,该用户的Profile设置会被自动加载。  
  如果匿名用户通过认证的话,所有与该用户相关的profile就会丢失,同时系统会生成一个新的profile。这时该Profile信息将与用户名相关联,而非唯一识别号。

Global.asax

这是petshop中将匿名的信息转为注册用户信息的代码:  
          void   Profile_MigrateAnonymous(Object   sender,   ProfileMigrateEventArgs   e)   {  
                  ProfileCommon   anonProfile   =   Profile.GetProfile(e.AnonymousID);  
   
                  //   Merge   anonymous   shopping   cart   items   to   the   authenticated   shopping   cart   items  
                  foreach   (CartItemInfo   cartItem   in   anonProfile.ShoppingCart.CartItems)  
                          Profile.ShoppingCart.Add(cartItem);  
   
                  //   Merge   anonymous   wishlist   items   to   the   authenticated   wishlist   items  
                  foreach   (CartItemInfo   cartItem   in   anonProfile.WishList.CartItems)  
                          Profile.WishList.Add(cartItem);  
   
                  //   Clean   up   anonymous   profile  
                  ProfileManager.DeleteProfile(e.AnonymousID);  
                  AnonymousIdentificationModule.ClearAnonymousIdentifier();  
                   
                  //   Save   profile  
                  Profile.Save();  
          }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

profile是2.0新出来的东西,ProfileCommon这个类是配好profile自动生成的,要查查profile启动匿名之后的处理机制,才知道Profile.UserName怎么回事

抱歉!评论已关闭.