ai教程入门教程 ASP.NET入门教程 11.7 管理匿名购物车
ASP.NET入门教程 11.7 管理匿名购物车
本章前面简要提及了存在如下配置文件属性
<profile enabled= true >]
<properities>
<add name= MemberName />
<add name= Cart serializeAs= Binary type=
Wrox Commerce ShoppingCart
allowAnoymous= true />根据每个用户会话的Profile Cart值a lowAnonymous标志指示匿名用户可以有购物车 在这种情况下 用户可能访问站点并且忽视登录 或者他们可能是该站点的全新用户 然后 该用户可以很愉快地使用商品填满购物篮 因此将由您来处理在已有的用户登录时将购物车切换给该用户 或者在匿名用户登录时创建新的配置文件 并且在该用户尝试结账时将购物车转换给新创建的用户
在Gtobal asax文件中存在处理这种转换的代码 该文件处理由代码引发的全局事件 下面是在Wrox United应用程序中使用的代码
Public Sub Profile_OnMigrateAnonymous(ByVal Sender As Object ByVal e As ProfileMigrateEventArgs)
get the profile for the anonymous user
Dim anonProfile As ProfileCommon = Profile GetProfile(e AnonymousID)
if they have a shopping cart then migrate that to the authenticated user

If anonProfile Cart IsNot Nothing Then
If Profile Cart Is Nothing Then
profile Cart = New Wrox Commerce ShoppingCart()
profile Cart Items AddRange(anonProfile Cart Items)
end if
anonProfile Cart = Nothing
End If
ProfileManager DeleteProfile(e AnonymousID)
AnonymousIdentificationModule ClearAnonymousIdentifier()
End Sub
在第 章中确切地查看购物体验的工作原理时将更为详细地研究这段代码 但理解如下内容将非常有用 在作为用户登录时需要理解很多结果 并且从一个配置文件到另一个配置文件的购物车转换是最为重要的 因为不可以针对匿名用户实际地设置任何其他的属性
lishixinzhi/Article/program/net/201311/15532相关文章
- ado五个对象 ASP.NET入门教程 13.3.1 购物对象[1]
- ado五个对象 ASP.NET入门教程 13.3.1 购物对象[5]
- 尤克里里教程入门教程 ASP.NET入门教程 13.4.5 计划结账[6]
- 位运算符怎么运算 ASP.NET入门教程 9.2.1 运算符[5]
- 当当网上购物书店购物车 ASP.NET项目开发指南:网络书店订单的发货和作废(2)
- aspnet项目开发教程 ASP.NET入门教程 12.8 综合整理[2]
- 加入购物车 ASP.NET入门教程 13.3.3 购物车控件[2]
- 书店怎么经营 ASP.NET项目开发指南:网络书店系统预览
- 清空购物车 ASP.NET入门教程 13.3.3 购物车控件[3]
- 产品验证页面 ASP.NET入门教程 13.2.4 产品项页面[2]
爱学记

微信收款码
支付宝收款码