日期:2014-05-18  浏览次数:20462 次

我在CS文件中编译为何说没有System.Web.HttpContext.Current.Session?(ASP.NET1.1)
using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.SessionState;
using   System.Web.HttpContext.Current.Session;


namespace   WebMonitor.Util
{
///   <summary>
///   SessionUtil   的摘要说明。
///   </summary>
public   class   SessionUtil
{
public   static   String   GetSession(String   sessionName)
{
return   Session[sessionName].ToString();
}

public   static     String   SetSession(String   sessionName,String   sessionValue)
{
Session[sessionName]   =   sessionValue;
}

public   static     bool   IsSessionSet(String   sessionName)
{
return   Session[sessionName]==null?false:true;
}

}
}


------解决方案--------------------
去掉using System.Web.HttpContext.Current.Session;
写成
System.Web.HttpContext.Current.Session[sessionName] = sessionValue;
------解决方案--------------------
public static String GetSession(String sessionName)
{
return Session[sessionName].ToString(); // 假如 Session[sessionName] == null ,调用此方法就翘鞭子了 ...
}