Re: Sessions variable access in multithreaded asp.net

Discussion in 'ASP .Net' started by Natty Gur, Jul 28, 2003.

  1. Natty Gur

    Natty Gur Guest

    Hi,

    As far as I know you can’t access Session from another thread directly
    or by using HttpContext.Current, you should get null from
    HttpContext.Current. The work around that I use is to pass the Context
    as parameter to the thread.

    see my sample : http://www.developersdex.com/gurus/code/662.asp.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jul 28, 2003
    #1
    1. Advertising

  2. Hi,

    Thanks, but i noticed that u need to have the Join method or else the
    HttpContext.Session will still be null. Wouldn't that defeat the
    purpose of multithreading then?

    Natty Gur <> wrote in message news:<>...
    > Hi,
    >
    > As far as I know you can?t access Session from another thread directly
    > or by using HttpContext.Current, you should get null from
    > HttpContext.Current. The work around that I use is to pass the Context
    > as parameter to the thread.
    >
    > see my sample : http://www.developersdex.com/gurus/code/662.asp.
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 28th Baruch Hirsch st. Bnei-Brak
    > Israel , 51114
    >
    > Phone Numbers:
    > Office: +972-(0)3-5786668
    > Fax: +972-(0)3-5703475
    > Mobile: +972-(0)58-888377
    >
    > Know the overall picture
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Kelvin Foo Chuan Lyi, Jul 29, 2003
    #2
    1. Advertising

  3. Natty Gur

    Natty Gur Guest

    Hi,

    You dont have to use the join method ...

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jul 29, 2003
    #3
  4. If you spawn the thread and don't wait, then whats the point. The page will
    get served without your thread ever getting back. Then all the processing
    that you are doing in the thread is waste. At some point you will have to
    wait for the threrad to finish execution.

    --
    Naveen K Kohli
    http://www.netomatix.com
    "Kelvin Foo Chuan Lyi" <> wrote in message
    news:...
    > Hi,
    >
    > Thanks, but i noticed that u need to have the Join method or else the
    > HttpContext.Session will still be null. Wouldn't that defeat the
    > purpose of multithreading then?
    >
    > Natty Gur <> wrote in message

    news:<>...
    > > Hi,
    > >
    > > As far as I know you can?t access Session from another thread directly
    > > or by using HttpContext.Current, you should get null from
    > > HttpContext.Current. The work around that I use is to pass the Context
    > > as parameter to the thread.
    > >
    > > see my sample : http://www.developersdex.com/gurus/code/662.asp.
    > >
    > > Natty Gur, CTO
    > > Dao2Com Ltd.
    > > 28th Baruch Hirsch st. Bnei-Brak
    > > Israel , 51114
    > >
    > > Phone Numbers:
    > > Office: +972-(0)3-5786668
    > > Fax: +972-(0)3-5703475
    > > Mobile: +972-(0)58-888377
    > >
    > > Know the overall picture
    > >
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > > Don't just participate in USENET...get rewarded for it!
     
    Naveen K Kohli, Aug 5, 2003
    #4
    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. David Browne
    Replies:
    1
    Views:
    493
    Kelvin Foo Chuan Lyi
    Jul 29, 2003
  2. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,426
    Luther Miller
    Aug 8, 2003
  3. Richard Bird  CCNP, CCDP, MCSE, etc.

    Multithreaded Telnet sessions

    Richard Bird CCNP, CCDP, MCSE, etc., Jun 14, 2004, in forum: Python
    Replies:
    6
    Views:
    505
    Josiah Carlson
    Jul 2, 2004
  4. scottymo
    Replies:
    3
    Views:
    779
    Dominick Baier
    Sep 30, 2006
  5. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    606
    Bookham Measures
    Aug 23, 2007
Loading...

Share This Page