Buenos días, el problema es el siguiente:
Modifique un carrito de compras que me encontré en la red, todo bien, el gran problema es que al introducir un articulo en el carrito en la maquina X este me aparece agregado también en la maquina Y y Z. Creo que el problema abajo, pero no logro captarlo.
Alguien tiene ideas?
#Region "Singleton Implementation"
' Readonly variables can only be set in initialization or in a constructor
Public Shared ReadOnly Instance As ShoppingCart
' The static constructor is called as soon as the class is loaded into memory
Shared Sub New()
' If the cart is not in the session, create one and put it there
' Otherwise, get it from the session
If HttpContext.Current.Session("ASPNETShoppingCart") Is Nothing Then
Instance = New ShoppingCart()
Instance.Items = New List(Of CartItem)
HttpContext.Current.Session("ASPNETShoppingCart") = Instance
Else
Instance = CType(HttpContext.Current.Session("ASPNETShoppingCart"), ShoppingCart)
End If
End Sub
' A protected constructor ensures that an object can't be created from outside
Protected Sub New()
End Sub
#End Region
Modifique un carrito de compras que me encontré en la red, todo bien, el gran problema es que al introducir un articulo en el carrito en la maquina X este me aparece agregado también en la maquina Y y Z. Creo que el problema abajo, pero no logro captarlo.
Alguien tiene ideas?
#Region "Singleton Implementation"
' Readonly variables can only be set in initialization or in a constructor
Public Shared ReadOnly Instance As ShoppingCart
' The static constructor is called as soon as the class is loaded into memory
Shared Sub New()
' If the cart is not in the session, create one and put it there
' Otherwise, get it from the session
If HttpContext.Current.Session("ASPNETShoppingCart") Is Nothing Then
Instance = New ShoppingCart()
Instance.Items = New List(Of CartItem)
HttpContext.Current.Session("ASPNETShoppingCart") = Instance
Else
Instance = CType(HttpContext.Current.Session("ASPNETShoppingCart"), ShoppingCart)
End If
End Sub
' A protected constructor ensures that an object can't be created from outside
Protected Sub New()
End Sub
#End Region