你看看Web.Config里面是否把Session Disable掉了

解决方案 »

  1.   

    没有啊,
    Web.config中:<sessionState 
                mode="InProc"
                stateConnectionString="tcpip=127.0.0.1:42424"
                sqlConnectionString="data source=127.0.0.1;user id=sa;password="
                cookieless="false" 
                timeout="20" 
        />
      

  2.   

    对不起,没注意
    你不能在构造器里面使用Session,因为这个时候,Page的Session属性还没有
    不过你可以使用HttpContext.Current.Session
      

  3.   

    HttpContext.Current.Session如何使用?在基类中嘛?
      

  4.   

    不过你最好不要这样做
    你可以在PageBase中重载OnLoad方法,在这里面检查权限
      

  5.   

    或者这样:
    protected virtual void Page_Load(object sender, System.EventArgs e)
    {
    CheckUserSession();
    }protected override void OnInit(EventArgs e)
    {
    this.Load += new EventHandler( this.Page_Load );
    base.OnInit(e);
    }
      

  6.   

    好了,非常感谢(timmy3310(tim))!
    非常感谢(timmy3310(tim))!