Add Session varaible in an ordinary class

Discussion in 'ASP .Net' started by RonL, Apr 2, 2006.

  1. RonL

    RonL Guest

    I'm unable to add a session variable in a non-page class. Any ideas?

    I've tried

    System.Web.SessionState.HttpSessionState session =
    HttpContext.Current.Session;

    session["ABC"] = messageBody;



    also

    System.Web.SessionState.HttpSessionState session =
    HttpContext.Current.Session;

    session.Add("ABC", messageBody");



    also



    HttpContext current = HttpContext.Current;

    current.Session["ABC"] = messageBody;



    Ron
     
    RonL, Apr 2, 2006
    #1
    1. Advertising

  2. RonL

    RonL Guest

    I jsut noticed that it does not work if there no session variables exist. If
    I add a different Session variable in a start up page then it works fine.

    Ron


    "RonL" <> wrote in message
    news:5WEXf.7443$...
    > I'm unable to add a session variable in a non-page class. Any ideas?
    >
    > I've tried
    >
    > System.Web.SessionState.HttpSessionState session =
    > HttpContext.Current.Session;
    >
    > session["ABC"] = messageBody;
    >
    >
    >
    > also
    >
    > System.Web.SessionState.HttpSessionState session =
    > HttpContext.Current.Session;
    >
    > session.Add("ABC", messageBody");
    >
    >
    >
    > also
    >
    >
    >
    > HttpContext current = HttpContext.Current;
    >
    > current.Session["ABC"] = messageBody;
    >
    >
    >
    > Ron
    >
    >
     
    RonL, Apr 2, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Razvan
    Replies:
    1
    Views:
    380
    Tor Iver Wilhelmsen
    Sep 30, 2004
  2. prabhu
    Replies:
    3
    Views:
    789
    Roger Leigh
    Jan 27, 2004
  3. Lewap
    Replies:
    1
    Views:
    382
    Sumit Rajan
    Jan 24, 2005
  4. jhduplessis

    Display varaible on LCD

    jhduplessis, Nov 7, 2007, in forum: VHDL
    Replies:
    0
    Views:
    593
    jhduplessis
    Nov 7, 2007
  5. Hang

    Is varaible name case sensitive?

    Hang, Jul 9, 2003, in forum: ASP General
    Replies:
    3
    Views:
    157
Loading...

Share This Page