您现在的位置是:首页 >

ai教程入门教程 ASP.NET入门教程 11.7 管理匿名购物车

火烧 2022-10-10 10:05:59 1043
ASP.NET入门教程 11.7 管理匿名购物车 本章前面简要提及了存在如下配置文件属性 lt rofile e a led= true gt ] lt ro eritie gt lt add ame

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

ai教程入门教程 ASP.NET入门教程 11.7 管理匿名购物车

        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  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码