我SHOPING車應用程序我使用下面的代碼,以保持Cart.There舉行會議一個錯誤,當我打開我的網站在更多然後到瀏覽器有會議衝突,當我從我的一個瀏覽器,然後選擇到另一個項目,所以先前創建的會話更新 ,但必須有每個瀏覽器的新會話 請有人幫助我瞭解會話中的錯誤的區域。我對着會話衝突錯誤在我的網站
#region Singleton Implementation
// Readonly properties can only be set in initialization or in a constructor
public static readonly ShoppingCart Instance;
// The static constructor is called as soon as the class is loaded into memory
static ShoppingCart()
{
// If the cart is not in the session, create one and put it there
// Otherwise, get it from the session
if (HttpContext.Current.Session["ShoppingCart"] == null)
{
Instance = new ShoppingCart();
Instance.Items = new List<CartItem>();
HttpContext.Current.Session.Add("ShoppingCart", Instance);
}
else
{
Instance = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
}
}
// A protected constructor ensures that an object can't be created from outside
protected ShoppingCart() { }
#endregion
的聲明謝謝親愛的,但我得到了解決方案。 –