locked
Loosing certain sessions RRS feed

  • Question

  • User994805612 posted

    Good dayt to you all

    I have (like everybody else) a very strange problem.

    I have a asp.net page with a codebehind. I have 2 buttons on the page

    -----------------------------------------------

    When clicking on button 1 I get some data from my database and save it for later use in Sessions.

    Session("TestTageF") = TageF.ToString
            Session("TestTageZF") = TageZF.ToString
            Session("TestTageS") = TageS.ToString
            Session("TestTageZH") = TageZH.ToString
            Session("TestTageH") = TageH.ToString
            Session("TestTageFeier") = TageFeier.ToString
            Session("TestPreisF") = PreisF.ToString
            Session("TestPreisZF") = PreisZF.ToString
            Session("TestPreisS") = PreisS.ToString
            Session("TestPreisZH") = PreisZH.ToString
            Session("TestPreisH") = PreisH.ToString
            Session("TestPreisFeier") = PreisFeier.ToString
            Session("TestTotalPreisF") = TotalPreisF.ToString
            Session("TestTotalPreisZF") = TotalPreisZF.ToString
            Session("TestTotalPreisS") = TotalPreisS.ToString
            Session("TestTotalPreisZH") = TotalPreisZH.ToString
            Session("TestTotalPreisH") = TotalPreisH.ToString
            Session("TestTotalPreisFeier") = TageFeier.ToString
            Session("TotalPreisAlle") = TotalPreisAlle.ToString
     
    When I click on button 2 I use the values from the sessions to do some stuff.
     
    PROBLEM
    Sometimes I seem to loose 
     
        Session("TestPreisF") = PreisF.ToString
            Session("TestPreisZF") = PreisZF.ToString
            Session("TestPreisS") = PreisS.ToString
            Session("TestPreisZH") = PreisZH.ToString
            Session("TestPreisH") = PreisH.ToString
            Session("TestPreisFeier") = PreisFeier.ToString
    
    All others seem to be ok.
     
    On the same page I have the same problem with another Session
    -----------------------
     
    I am not able to reproduce it unfortunately.
     
    What I know
    - Not all sessions are lost, just some are missing which seems to me that it can not be timeout or reset.
    - It's not like the first 4 or last 4 get lost so I could assume some App_Pool recycling just happened the very splitsecond.
    - It is not consistent and I can not reproduce it.
    ------------------
    Anyone with a wild idea why I could have Sessions that are either lost or empty?
     
    Markus


     

     

    Wednesday, February 9, 2011 6:34 AM

Answers

All replies

  • User-693248168 posted

    Hi,

     

    If I was in your place, I would have identified all the places where I am altering the Session object. And then try to figure out if I am removing some session after some logic.

     

     

    Wednesday, February 9, 2011 7:34 AM
  • User1791120482 posted

    Could you please be more specific what you mean by loosing session?

    How are you reading it back?  How are you sure that session is lost for some of the variables.

    If Session is expired then all session variables will be cleaned up.  Its not like it clears some of them and keep others.

    Check out your code whether variables are saved to session properly or not in first place.

    Wednesday, February 9, 2011 7:41 AM
  • User994805612 posted

    @Lateef045

    Been there, done that

    @bala.sekhar

    I am just mailing me the values of the sessions. And sometimes there are some missing. And yes there are just some missing

    I found this link now, which could give a clue

    http://weblogs.asp.net/bleroy/archive/2004/08/03/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_.aspx

     

    session loss problems can also result from a misconfigured application pool. For example, if the application pool your site is running is configured as a web farm or a web garden (by setting the maximum number of worker processes to more than one), and if you're not using the session service or SQL sessions, incoming requests will unpredictably go to one of the worker processes, and if it's not the one the session was created on, it's lost.

    The solutions to this problem is either not to use a web garden if you don't need the performance boost, or use one of the out of process session providers.

    <o:p> </o:p>

    More on web gardens: http://technet2.microsoft.com/WindowsServer/en/library/f38ee1ff-bdd5-4a5d-bef6-b037c77b44101033.mspx?mfr=true

    <o:p> </o:p>

    How to configure IIS worker process isolation mode: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/26d8cee3-ec31-4148-afab-b6e089a0300b.mspx?mfr=true

    Thanks to Frédéric Gareau for pointing that out.

     

    Markus

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 9, 2011 7:45 AM
  • User-121157572 posted

    It seems like you don't have values in the database for some fields which you are assgining to session variable.

    There is very little chance of clearing the session value if you are not clearing it using some other code.



    Wednesday, February 9, 2011 7:47 AM