日期:2014-05-17  浏览次数:20802 次

session读取出错
这个专门读取Session的类session:
public static string GetSession(string strSessionName)
        {
            if (HttpContext.Current.Session[strSessionName] == null)
            {
                return null;
            }
            else
            {
                return HttpContext.Current.Session[strSessionName].ToString();
            }
        }

在另一个user类中引用
string xx=session.GetSession("urx");出现未将对象引用设置到对象的实例

面在页面(.aspx.cs)中引用就没有问题
请问如何解决

------解决方案--------------------
类session有没有实例化,在调用GetSession之前?
------解决方案--------------------
将HttpContext.Current传到你的User类里面就可以了。