Sessions variable access in multithreaded asp.net

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: Sessions variable access in multithreaded asp.net


    "Kelvin Foo Chuan Lyi" <vm@vmirage.cjb.net> wrote in message
    news:3c84a272.0307280615.48cb160f@posting.google.c om...
    > Hi guys,
    >
    > I've got a problem accessing Session variable in a thread. I keep
    > getting this serialization error thinggy... I'm using c# ... but i've
    > seen source accessing Sessions in threads using VB.Net .... odd...
    >
    > my code looks some what like this...
    >
    >
    > private void MyThread()
    > {
    > Session["test"] = "testing";
    > }
    >
    > note: MyThread is called by Thread.Start()
    >
    > i get this serialization error... um... forgot what error it was...
    > but it states that blah blah blah... does not support serialization
    > or somewhat like that... hmm... thread doesn't support serialization
    > rite? But using VB.Net ... i won't get such error... why? Any work
    > around for this?
    >
    If you are getting the error

    that blah blah blah...

    I suggest you figure it out yourself, and stop wasting everyone's time.

    Alternatively, you could post sample code and a real error message, and
    perhaps someone will help you.

    David


    David Browne Guest

  2. Similar Questions and Discussions

    1. Sessions Variable
      HI everyone Been trying to get sessions variables happening have set up a collection called 'shoppingcart' now im trying to get my add button to...
    2. CSharpCorner Just Published My Article : Multithreaded XML Documentfor Read/Write Access
      Check me out: http://www.c-sharpcorner.com/Code/2004/July/MultithreadedXmlDoc.asp Multithreaded XML Document for Read/Write Access by John...
    3. HELP : problem with sessions, and php code stored within a variable
      I am getting the following error on a peice of code of mine: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
    4. #26093 [NEW]: access variable cause access violation
      From: bruno dot faust at ig dot com dot br Operating system: XP SP1 latest PHP version: 4.3.3 PHP Bug Type: Reproducible...
    5. Sessions variable HELP please
      Hi Can Someone tell me why This doesnąt work: Page 1 $_SESSION = 'A non'; Page 2 Echo $_SESSION;
  3. #2

    Default Re: Sessions variable access in multithreaded asp.net

    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 : [url]http://www.developersdex.com/gurus/code/662.asp[/url].

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: Sessions variable access in multithreaded asp.net

    >
    > If you are getting the error
    >
    > that blah blah blah...
    >
    > I suggest you figure it out yourself, and stop wasting everyone's time.
    >
    > Alternatively, you could post sample code and a real error message, and
    > perhaps someone will help you.
    >
    > David
    sorry dude... but my source code was in my office ... and i'm writing
    the message at home... and i can remember a little of what happened in
    my brain... :P
    Kelvin Foo Chuan Lyi Guest

  5. #4

    Default Re: Sessions variable access in multithreaded asp.net

    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 <natty@dao2com.com> wrote in message news:<esBz04RVDHA.3220@tk2msftngp13.phx.gbl>...
    > 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 : [url]http://www.developersdex.com/gurus/code/662.asp[/url].
    >
    > 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 [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    Kelvin Foo Chuan Lyi Guest

  6. #5

    Default Re: Sessions variable access in multithreaded asp.net

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  7. #6

    Default Re: Sessions variable access in multithreaded asp.net

    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
    [url]http://www.netomatix.com[/url]
    "Kelvin Foo Chuan Lyi" <vm@vmirage.cjb.net> wrote in message
    news:3c84a272.0307282134.7ea4025b@posting.google.c om...
    > 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 <natty@dao2com.com> wrote in message
    news:<esBz04RVDHA.3220@tk2msftngp13.phx.gbl>...
    > > 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 : [url]http://www.developersdex.com/gurus/code/662.asp[/url].
    > >
    > > 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 [url]http://www.developersdex.com[/url] ***
    > > Don't just participate in USENET...get rewarded for it!

    Naveen K Kohli Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139