auto session check with override

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rony_16@017.net.il

    #1

    auto session check with override

    hi ,
    i want to override the object session in class page , because i want to

    check the Session["UserName"] automaticly in WebForm , without writing
    "if" in evry page .


    i know that i need to make a new class Lib and inharite from "page" .
    but what should i write in the fuction "public override
    HttpSessionStat e
    Session" ???


    Please Help me !!!

  • Siva M

    #2
    Re: auto session check with override

    Have your session checking in the PreRequestHandl erExecute event handler (in
    global.asax)

    <rony_16@017.ne t.il> wrote in message
    news:1133952669 .149151.53750@z 14g2000cwz.goog legroups.com...
    hi ,
    i want to override the object session in class page , because i want to

    check the Session["UserName"] automaticly in WebForm , without writing
    "if" in evry page .


    i know that i need to make a new class Lib and inharite from "page" .
    but what should i write in the fuction "public override
    HttpSessionStat e
    Session" ???


    Please Help me !!!


    Comment

    • rony_16@017.net.il

      #3
      Re: auto session check with override

      i tried to write it in global.asax but in
      Application_Aut henticateReques t

      protected void Application_Aut henticateReques t(Object sender, EventArgs
      e)
      {
      string str;
      str=Session["UserName"].ToString();
      if (str==null) { Response.Redire ct ("WebForm1.aspx "); }

      }

      but it do not works!!!
      the ERROR is : System.Web.Http Exception: Session state is not available
      in this context.

      do you have any sugestions?

      Comment

      • Siva M

        #4
        Re: auto session check with override

        True. Session wouldn't have been created when the AuthenticateReq uest event
        is called. Session object is created only after AcquireRequestS tate event.

        <rony_16@017.ne t.il> wrote in message
        news:1133976130 .704927.92100@o 13g2000cwo.goog legroups.com...
        i tried to write it in global.asax but in
        Application_Aut henticateReques t

        protected void Application_Aut henticateReques t(Object sender, EventArgs
        e)
        {
        string str;
        str=Session["UserName"].ToString();
        if (str==null) { Response.Redire ct ("WebForm1.aspx "); }

        }

        but it do not works!!!
        the ERROR is : System.Web.Http Exception: Session state is not available
        in this context.

        do you have any sugestions?


        Comment

        Working...