Mam następujący kod, który używa sesji, ale mam błąd w linii:„sesja” nie istnieje w bieżącym kontekście
if (Session["ShoppingCart"] == null)
błąd jest cS0103: The name 'Session' does not exist in the current context
czym polega problem?
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Web.SessionState;
/// <summary>
/// Summary description for ShoppingCart
/// </summary>
public class ShoppingCart
{
List<CartItem> list;
public ShoppingCart()
{
if (Session["ShoppingCart"] == null)
list = new List<CartItem>();
else
list = (List<CartItem>)Session["ShoppingCart"];
}
}
która metoda? masz na myśli konstruktora? w innej klasie – Adham
Wywołujesz go ze strony innej niż sesja - lub z wątku. – Aristos