大小写错了!
Session["OP"].toString ! = "1"  ->Session["OP"].ToString() ! = "1"

解决方案 »

  1.   

    将session过期的时间设长些:
    this.Session.Timeout = 20;
      

  2.   

    搂主说的错误好像是出现在第一句,是不是没有大写? Response.redirect ("login.aspx")Response.Redirect("login.aspx",true);加参数true,程序会中止执行
      

  3.   

    if (Session["OP"] == nothing) 
    不过我没试过,你试试看吧
    session 过期后是不存在了还是为null?
      

  4.   

    if(((String)Session["OP"])!="1")
    ......
      

  5.   

    原文件的大小写正确,贴子上是错的。正如冷冻微笑所说:session过期后是不存在还是为null?
    如若为null,则我的判断没有错误,何以报“没有将对象引用到实例上”的错误。
    如若不存在,请问如何判断?急!各位大虾多帮忙,分不够再加!
      

  6.   

    是正确的判断出现这个错误应该是别的地方,你看看异常信息的StackTrace里面的信息是哪一行出错
      

  7.   

    我的原程序如下:
    if (Session["OP"].ToString() == null)//这句报错:未将对象引用到实例上
    Response.Redirect ("Login.aspx");
    else
    {
    //Response.Write (OP);
    if (Session["OP"].ToString() != "1")
    Response.Write ("<script>alert('对不起,你没有权限!');history.go(-1)</script>");

                 }
      

  8.   

    if (Session["OP"].ToString() == null)
    改为
    if (Session["OP"] == null)Session["OP"]本身就是null,不能在一个null上面调用ToString()方法
      

  9.   

    agree with timmy3310(Tim)
    !