判断session不为空的最好方法

时间:2022-04-25 20:59:39

 if (Session["userid"] != null)
        {
            userid = Session["userid"].ToString();

            ViewState["userid"] = userid;
        }
        else
        {
            if (ViewState["userid"] != null)
            {
                userid = ViewState["userid"].ToString();
            }
            else
            {
               
                CommonFuns.SessinAbandonDeal(this);
                return;
            }

        }