if(Session["Admin"]==null)
{
}

解决方案 »

  1.   

    表示对象为空应该用null
    表示字符串为空才用""
      

  2.   

    null也不行啊,我试过了
    异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 30:  private void Page_Load(object sender, System.EventArgs e)
    行 31:  {
    行 32:  if(Session["admin"] == null)
    行 33:  {
    行 34:  Response.Write("错误的访问");
     
      

  3.   

    楼主注意大小写
    session是对象,可以用null来判断
    我一直这样做
      

  4.   

    我是直接在浏览器中输入地址(跳过验证)出现错误的
    楼上的注意大小写是什么大小写?Session["admin"]??
      

  5.   

    Session["Admin"]  <>  Session["admin"]
      

  6.   

    那么当数据库中某个字段的值有的为空,
    那么用SQL语句如何把该字段为空的所有记录都选择出来呢?
    select * from table1 where mytest=""
    select * from table1 where mytest=null
    我都试过了,都不行,到底怎么判断呢?
      

  7.   

    同意 zq_hhu(海鸥飞飞) 的看法……
      

  8.   

    Session、Application中的Key是不分大小写的,Session、Application好象是用Hashtable来实现的。。
      

  9.   

    select * from table1 where mytest=""
    select * from table1 where mytest=null这两句有点问题,如果数据库中的数据为null(而不是""),则select * from table1 where mytest=""是取不到任何数据的;
    select * from table1 where mytest=null也有语法错误,应该是mytest is null这样应该没有什么问题了。关于session的判断问题,如果Session["Admin"]==""或者==null都有问题的话,不妨这样判断:if len(session("admin"))=0) then
    .....
    end if试一下就知道了