locked
Session variables dropped between pages RRS feed

  • Question

  • User1072762708 posted

    I've got a local intranet where i store some session variables between pages. The site is on a standalone windows 2k3 box.

    We recently started virtualizing, and the DEV copy of the site now lives on a Virtualized 2k8 box. I wrote a very basic page that creates a session variable but when the user is directed to the next page, the session has lost it's value.

    To simplify things i made two very generic pages. No master pages, no AJAX, nothing but a label on one and a text box and button on the other to set a session variable. Again, when i set the session variable on Page A, I can see a value in the session. When i go to the other page (either through a site map menu, typing the new page into the browser, or hitting a link, the session is set to null again.

    Anyone have any ideas on where to start with solving this issue?

    Tuesday, March 22, 2011 2:26 PM

Answers

  • User1072762708 posted

    And the issue has been resolved. The big difference in the url was i had appended '_dev' to the dev sitename. Apparently sessions hates underscores.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 25, 2011 9:15 AM
  • User1324895001 posted

    I had issues with session naming, but dont recall if it was due to underscores..glad you got it worked out.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 25, 2011 10:24 AM

All replies

  • User1324895001 posted

    See if this other post helps trouble shoot some..

    http://forums.asp.net/t/998370.aspx/1?losing+session+values

     

    Tuesday, March 22, 2011 4:18 PM
  • User1072762708 posted

    Hello. I tried some of the things outlined in that thread, namely adding the session tags to my web.config and setting it to using State Server. The Web.Config on my PRD box didn't have any session settings. The Dev site still runs, but again no Session variables are persisting.

    I also cheked to make sure the ASP service referenced in the other thread was running.

    This is quite a weird problem, the only difference between the two sites (other than ones uses the PRD Db and one uses the DEV db) is that they are on different boxes. THe code is the exact same.

     

    Wednesday, March 23, 2011 2:41 PM
  • User1324895001 posted

    If you have a global.asax file in either site, you may want to check if there is any code within the Session logic

     

            protected void Session_Start(object sender, EventArgs e)
            {
    
            }
    
    
            protected void Session_End(object sender, EventArgs e)
            {
    
            }
    
    
    

    Also, have you checked how long the sessions last, default is 30 minutes, but could be adjusted to be longer and shorter, which is within IIS, example can be seen here

    http://forums.asp.net/t/1283350.aspx/1?How+to+increase+session+timeout+to+8+to+9hrs+

    Thursday, March 24, 2011 11:26 AM
  • User1072762708 posted

    Thanks for that reply. If nothing else I learned more about the various places that can affect session state.

    I looked at the suggestions on there. On my PRD box (i.e. the one that is handling session data correctly) this all looks to be on the same settings.

    My DEV box is on 2008, and IIS looks completely different. I ended up in the sessionstate area trying to figure out something in that regards.

    It seems in 2008 there are three session options now, inProc, SQL, and the ASP Service. Now keep in mind, back when i set up my prd box, i didn't configure a thing for Sessions, they just worked when i started using them. In the flavor of IIS running on 2008 there are suddenly all these options, and i noticed that as i changed from trying to use the service to InProc, it was editing the web.config file of the DEV website as well.

    However, none of these changes ended up making a difference. This is very frustratiing.

    I also took the time to check my global.asx, but there's nothing in there that is resetting the Sesion variables i'm trying to set in these other places. Again, the code in dev and prd are the exact same except for one SQL connection in the web.config, yet PRD works and DEV doesn't.

    The only difference that i can see is Win2k3/IIS6 vs Win2k8/IIS7, but i just can't figure out how to get 7 to work like 6 does. This is quite a problem for me since I'm being pushed to migrate my production server to our virtualized boxes (i.e. Win2k8).

     

    Thursday, March 24, 2011 12:33 PM
  • User1072762708 posted

    Also,

    If there's any screen shots of code or IIS configuration that would be helpful in trouble shooting this please let me know. I'll be happy to provide whatever.

    Thursday, March 24, 2011 12:42 PM
  • User1324895001 posted

    So far i havent experienced this issue and we are also on win2008 and IIS7

    check out this post:

    http://forums.asp.net/t/1101560.aspx/2/10?Session+timeout+not+working+properly

    http://stackoverflow.com/questions/949426/session-time-out-in-iis-7
    One of the answers here( Check the Windows Event Log to ensure that the Worker Process is not being forced to recyle. There may be something in your code that causes the Worker Process to force itself to recyle in which case when the session is stored inProc it will loose all session values it's holding.)

    Thursday, March 24, 2011 1:34 PM
  • User1072762708 posted

    Here's an update on the issue.. One of the server folks got the idea to try referencing the URL by IP instead of name, and the sessions work. When I try to use the server name (A record in DNS) it does not work. Hope this sheds some light on the subject.

    Once again thanks for all of the replys.

    Friday, March 25, 2011 8:54 AM
  • User1072762708 posted

    And the issue has been resolved. The big difference in the url was i had appended '_dev' to the dev sitename. Apparently sessions hates underscores.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 25, 2011 9:15 AM
  • User1324895001 posted

    I had issues with session naming, but dont recall if it was due to underscores..glad you got it worked out.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 25, 2011 10:24 AM