我在vs 2010中的Web项目中有一个cs类文件。 在课堂上,我阅读和wirte会话变量。 但我的Session属性为null!
我用这个:
public static int UserID
{
get
{
if (HttpContext.Current.Session["UserID"] == null) return 0;
return int.Parse(HttpContext.Current.Session["UserID"].ToString());
}
set
{
HttpContext.Current.Session["UserID"] = value;
}
}
但我的HttpContext.Current.Session为null(没有HttpContext.Current.Session [“x”])
注意网页项目没有App_Code文件夹。
如何在班上使用会话?