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

.net自定义类中Session 存值说未将对象引用设置到对象的实例
 public int intUserID
        {
            set
            {
                if (value != null)
                {
                    int intUserID;
                    if (int.TryParse(value.ToString(), out intUserID))
                    {
                        
                        HttpContext.Current.Session["UserID"] = intUserID;
                    }

                }
            }
            get
            {

                if (HttpContext.Current.Session["UserID"] == null)
                {
                    return -1;
                }
                else
                {
                    try
                    {
                        return Convert.ToInt32(HttpContext.Current.Session["UserID"].ToString());

                    }
                    catch (Exception)
                    {
                        return -1;
                    }
                }
      &