null是不能ToString()的.要判断Session["name"]==null

解决方案 »

  1.   

    一楼正解,要先判断是否==null
      

  2.   

    session为null的时候不能.tostring() 否则会出错
    判断session[""]==""||session[""]==null即可
      

  3.   

    if(Session["name"] ==null || Session["name"].ToString()=="") 
                    { 
                            Response.Write(" <script> alert('网页过期,请重新登陆!');window.close() </script> "); 
                    } 
      

  4.   

     if (Session["s"] != null)
    {
                this.TextBox1.Text = Session["s"].ToString();
     }
      

  5.   

    if(Session["name"] ==null) 
                    { 
                            if(Session["name"].ToString().Length>0)
                            {                         Response.Write(" <script> alert('网页过期,请重新登陆!');window.close() </script> "); 
                            }
                    } 
      

  6.   

    if (Convert.ToString(Session["LoginID"]) == "" ||Convert.ToString(Session["LoginID"]) == null)
    {
     Response.Redirect("../return.aspx");
    }
      

  7.   

    Session["name"]==null
    Session["name"]为null时是不能.ToString()
      

  8.   

    if(Session["name"].ToString()==string.Empty ¦ ¦Session["name"].ToString()=="") 
                    { 
                            Response.Write(" <script> alert('网页过期,请重新登陆!');window.close() </script> "); 
                    }