C# Cannot check Session exists?

前端 未结 8 2011
遥遥无期
遥遥无期 2020-12-14 20:26

I get an error when I do the following:

if(Session[\"value\"] != null)
{
   // code
}

The error i get is this:

Object reference not

8条回答
  •  伪装坚强ぢ
    2020-12-14 21:05

    I solve by this way:

    if (Session.Count > 0 && Session["mySessionVariable"].ToString() != null)
    {
    
    }
    

提交回复
热议问题