Session Object Craziness

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

  1. #1

    Default Re: Session Object Craziness

    I can't find anything technically wrong with what you are describing.

    This might just be a nit-picky detail, but - you said that the Session
    Object isn't created the first time
    and is created on the refresh. The fact that TestCache.aspx displays a
    SessionID makes me think
    that the Session has been created, but the Session variables just haven't
    been written. Without seeing
    the code that is actually writing the Session variables, I can't say for
    sure, but is it possible that there is some
    conditional condition not being satisfied on the initial run (something like
    Page.IsPostBack maybe?) that is keeping the session
    variables from being written?

    Hope this helps.

    Jeff Trotman
    Westglenn Software



    "BGS" <bgs@_NOSPAM_msn.com> wrote in message
    news:vhbkkr174akeba@corp.supernews.com...
    > I am having a maddening problem with my web site. The pages generally
    > consist of an ASP page, in which there is an inline frame (<iframe>) that
    > contains a "slide show" of photos. This inline frame holds an ASPX page,
    > with code behind written in C#. The ASPX page relies on the Session
    Object
    > to hold information about which slide show is being viewed and which photo
    > is current (so the "next", "previous" and "beginning" buttons will know
    > where to go in the sequence).
    >
    > All of this works perfectly, EXCEPT --
    >
    > When the user FIRST comes to one of the pages with this inline frame, for
    > some reason ASP.NET often does not create the Session Object. The first
    > photo loads normally, but when the user clicks on the "next" button, an
    > error (usually a Session Out error) occurs (and the user is taken to a
    > custom error page). If the user clicks the "Refresh" ("Reload") button on
    > the browser, the whole page (including the inline frame) reloads and
    > everything then proceeds as desired. In fact, when the user first comes
    to
    > the site, if he/she causes even just the inline frame to reload (by
    > right-clicking in the frame), the Session Object will be created and
    > everything proceeds as desired.
    >
    > To see this in action go to: [url]http://www.on-the-matrix.com/africa/index.asp[/url]
    > (this is one of many pages with the inline frame slide show).
    >
    > To confirm that nothing is written to the Session Object, go to:
    > [url]http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx[/url] (which lists
    > all cookies and the contents of the Session Object).
    >
    > Further information:
    >
    > 1. Both the ASP page and the ASPX page that loads in the inline frame
    > validate (as per [url]http://validator.w3.org/detailed.html[/url]). The ASP page is
    > HTML 4.01 Transitional and the inline ASPX page is XHTML 1.0 Transitional.
    >
    > 2. There are no JavaScript errors (according to Mozilla's console) as I
    move
    > through the photos or go from page to page.
    >
    > 3. In the .NET code behind, it appears as if the Session Object is being
    > created. If I test in the code behind to see if Session.Count > 0, it
    comes
    > back true. Yet if I go to the test page listed above, Session.Count comes
    > back as 0. (By the way, I am using the "InProc" mode of maintaining
    session
    > state with cookies.)
    >
    > 4. I tried having the ASP page write a cookie (called "StartCookie") the
    > first time any page was loaded. The inline ASPX page, through JavaScript,
    > read this cookie and if it was the first time the page was loaded,
    > JavaScript would cause a "location.reload(true)" that would reload the
    > inline ASPX page. This caused some annoying double flashing of the photo,
    > but otherwise worked perfectly on my home system and the Session Object
    was
    > always created when the ASPX page reloaded. For some reason, however, the
    > StartCookie does not get written on my host server.
    >
    > 5. I can tell from my web stats that it is not just my browsers (IE and
    > Mozilla) that are causing the problem. Many visitors experience the
    problem
    > and it occurs with both IE, Mozilla and recent versions of Netscape (older
    > versions get a page without the inline frame).
    >
    > 6. Both the ASP page and the inline ASPX photo page are created from XML
    > data transformed on the server using XSL stylesheets. Again, as noted,
    all
    > the resulting HTML validates.
    >
    > 7. By the way, I am NOT trying to access a Session Object created in ASP
    > with an ASPX page (I already learned that one). The ASPX page both
    creates
    > the Session Object and reads it.
    >
    > 8. As noted, once users get past the first page, everything works as
    > intended. It is only when the user FIRST comes to a page with a slide
    show
    > that the Session Object is not created.
    >
    > I hope somebody has some ideas. This is driving me absolutely NUTS!
    >
    > All help greatly appreciated,
    > Bruce
    >
    >

    Jeff Trotman Guest

  2. Similar Questions and Discussions

    1. Date Format craziness
      I have a DateChooser {dateChooserWeekEnding} When I update the bound DateObject the display changes from MM/DD/YY ( 04/14/2008 ) to ddd, mmm dd...
    2. adodb.recordset object and the IIS session object
      I was looking through the registry of a Windows 2000 Adv. Server I just built and noticed that the adodb.recordset object had been set to "both"...
    3. Retrieving Object from a Session
      When i try to retrieve and object from the $_SESSION variable on a new page the object contains no data. For example <?php /* Get user info ...
    4. [PHP] Object in session and include
      Chris, Your impression is correct, but sounds a little misleading. The include_once will only include the file if it has not yet been included in...
    5. Object can not be used after a session
      Hi I was wondering if anybody has any Ideas about or has experienced this.... I create a new object and then assign it to a session var ...
  3. #2

    Default Re: Session Object Craziness

    Hi Jeff,

    Thanks for having a look at my site and your thoughts.

    I did review the code again and the mystery only deepens. I do not use (and
    therefore do not test for) a PostBack. Thus, whether the page is loaded
    initially, or on a browser induced reload, exactly the same code executes.
    You are quite right (as TestCache.aspx confirms) that a Session is created
    and is assigned a Session ID even though objects saved to the Session Object
    do not appear. I can tell from the web stats that even when a user reloads
    the initial page and the Session Object then begins to work as intended, the
    same Session ID is maintained.

    Here's the mysterious part: If the user is coming to a slide show for the
    first time (tested by what appears in the query string), the code behind
    loads an XSL stylesheet from the disc and places it in the Session Object
    (this same stylesheet is used for all photos). After getting the stylesheet
    (and manipulating some XML with information about the photo), a separate
    method (called RenderPage() ) is called.

    The RenderPage() method gets the XSL stylesheet FROM THE SESSION OBJECT and
    transforms the XML to display the photo and related information. Thus, the
    code behind is able to access the Session Object (or else we would never see
    the first photo). After the photo renders, there is nothing in the code
    that would wipe away the Session Object. Proof of this comes from the fact
    that the very same RenderPage() method is called on a reload (and is also
    called to display all subsequent photos in the slide show) and the Session
    Object remains intact.

    Only when a user FIRST comes to the web site does the Session Object somehow
    disappear.

    As always, I appreciate any ideas that you, or other members of the group,
    may have.
    Bruce



    "Jeff Trotman" <jtrotman@westglenn.com> wrote in message
    news:uXOP2oBTDHA.1320@TK2MSFTNGP12.phx.gbl...
    > I can't find anything technically wrong with what you are describing.
    >
    > This might just be a nit-picky detail, but - you said that the Session
    > Object isn't created the first time
    > and is created on the refresh. The fact that TestCache.aspx displays a
    > SessionID makes me think
    > that the Session has been created, but the Session variables just haven't
    > been written. Without seeing
    > the code that is actually writing the Session variables, I can't say for
    > sure, but is it possible that there is some
    > conditional condition not being satisfied on the initial run (something
    like
    > Page.IsPostBack maybe?) that is keeping the session
    > variables from being written?
    >
    > Hope this helps.
    >
    > Jeff Trotman
    > Westglenn Software
    >
    >
    >
    > "BGS" <bgs@_NOSPAM_msn.com> wrote in message
    > news:vhbkkr174akeba@corp.supernews.com...
    > > I am having a maddening problem with my web site. The pages generally
    > > consist of an ASP page, in which there is an inline frame (<iframe>)
    that
    > > contains a "slide show" of photos. This inline frame holds an ASPX
    page,
    > > with code behind written in C#. The ASPX page relies on the Session
    > Object
    > > to hold information about which slide show is being viewed and which
    photo
    > > is current (so the "next", "previous" and "beginning" buttons will know
    > > where to go in the sequence).
    > >
    > > All of this works perfectly, EXCEPT --
    > >
    > > When the user FIRST comes to one of the pages with this inline frame,
    for
    > > some reason ASP.NET often does not create the Session Object. The first
    > > photo loads normally, but when the user clicks on the "next" button, an
    > > error (usually a Session Out error) occurs (and the user is taken to a
    > > custom error page). If the user clicks the "Refresh" ("Reload") button
    on
    > > the browser, the whole page (including the inline frame) reloads and
    > > everything then proceeds as desired. In fact, when the user first comes
    > to
    > > the site, if he/she causes even just the inline frame to reload (by
    > > right-clicking in the frame), the Session Object will be created and
    > > everything proceeds as desired.
    > >
    > > To see this in action go to:
    [url]http://www.on-the-matrix.com/africa/index.asp[/url]
    > > (this is one of many pages with the inline frame slide show).
    > >
    > > To confirm that nothing is written to the Session Object, go to:
    > > [url]http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx[/url] (which
    lists
    > > all cookies and the contents of the Session Object).
    > >
    > > Further information:
    > >
    > > 1. Both the ASP page and the ASPX page that loads in the inline frame
    > > validate (as per [url]http://validator.w3.org/detailed.html[/url]). The ASP page
    is
    > > HTML 4.01 Transitional and the inline ASPX page is XHTML 1.0
    Transitional.
    > >
    > > 2. There are no JavaScript errors (according to Mozilla's console) as I
    > move
    > > through the photos or go from page to page.
    > >
    > > 3. In the .NET code behind, it appears as if the Session Object is being
    > > created. If I test in the code behind to see if Session.Count > 0, it
    > comes
    > > back true. Yet if I go to the test page listed above, Session.Count
    comes
    > > back as 0. (By the way, I am using the "InProc" mode of maintaining
    > session
    > > state with cookies.)
    > >
    > > 4. I tried having the ASP page write a cookie (called "StartCookie") the
    > > first time any page was loaded. The inline ASPX page, through
    JavaScript,
    > > read this cookie and if it was the first time the page was loaded,
    > > JavaScript would cause a "location.reload(true)" that would reload the
    > > inline ASPX page. This caused some annoying double flashing of the
    photo,
    > > but otherwise worked perfectly on my home system and the Session Object
    > was
    > > always created when the ASPX page reloaded. For some reason, however,
    the
    > > StartCookie does not get written on my host server.
    > >
    > > 5. I can tell from my web stats that it is not just my browsers (IE and
    > > Mozilla) that are causing the problem. Many visitors experience the
    > problem
    > > and it occurs with both IE, Mozilla and recent versions of Netscape
    (older
    > > versions get a page without the inline frame).
    > >
    > > 6. Both the ASP page and the inline ASPX photo page are created from XML
    > > data transformed on the server using XSL stylesheets. Again, as noted,
    > all
    > > the resulting HTML validates.
    > >
    > > 7. By the way, I am NOT trying to access a Session Object created in ASP
    > > with an ASPX page (I already learned that one). The ASPX page both
    > creates
    > > the Session Object and reads it.
    > >
    > > 8. As noted, once users get past the first page, everything works as
    > > intended. It is only when the user FIRST comes to a page with a slide
    > show
    > > that the Session Object is not created.
    > >
    > > I hope somebody has some ideas. This is driving me absolutely NUTS!
    > >
    > > All help greatly appreciated,
    > > Bruce
    > >
    > >
    >
    >

    BGS Guest

  4. #3

    Default Re: Session Object Craziness

    I'm really grasping at straws here, but is it possible that something
    about setting the Session object is asynchronous (loading the XSL
    or something?) so that the code continues to run and try and read
    the object in the session variable but that the operation loading the
    file to begin with hasn't completed by the first time but by the time
    the refresh happens it has?

    Probably a stupid thought, but I can't think of anything else.


    "BGS" <bgs@_NOSPAM_msn.com> wrote in message
    news:vhdqcq4bkfc7b2@corp.supernews.com...
    > Hi Jeff,
    >
    > Thanks for having a look at my site and your thoughts.
    >
    > I did review the code again and the mystery only deepens. I do not use
    (and
    > therefore do not test for) a PostBack. Thus, whether the page is loaded
    > initially, or on a browser induced reload, exactly the same code executes.
    > You are quite right (as TestCache.aspx confirms) that a Session is created
    > and is assigned a Session ID even though objects saved to the Session
    Object
    > do not appear. I can tell from the web stats that even when a user
    reloads
    > the initial page and the Session Object then begins to work as intended,
    the
    > same Session ID is maintained.
    >
    > Here's the mysterious part: If the user is coming to a slide show for the
    > first time (tested by what appears in the query string), the code behind
    > loads an XSL stylesheet from the disc and places it in the Session Object
    > (this same stylesheet is used for all photos). After getting the
    stylesheet
    > (and manipulating some XML with information about the photo), a separate
    > method (called RenderPage() ) is called.
    >
    > The RenderPage() method gets the XSL stylesheet FROM THE SESSION OBJECT
    and
    > transforms the XML to display the photo and related information. Thus,
    the
    > code behind is able to access the Session Object (or else we would never
    see
    > the first photo). After the photo renders, there is nothing in the code
    > that would wipe away the Session Object. Proof of this comes from the
    fact
    > that the very same RenderPage() method is called on a reload (and is also
    > called to display all subsequent photos in the slide show) and the Session
    > Object remains intact.
    >
    > Only when a user FIRST comes to the web site does the Session Object
    somehow
    > disappear.
    >
    > As always, I appreciate any ideas that you, or other members of the group,
    > may have.
    > Bruce
    >
    >
    >
    > "Jeff Trotman" <jtrotman@westglenn.com> wrote in message
    > news:uXOP2oBTDHA.1320@TK2MSFTNGP12.phx.gbl...
    > > I can't find anything technically wrong with what you are describing.
    > >
    > > This might just be a nit-picky detail, but - you said that the Session
    > > Object isn't created the first time
    > > and is created on the refresh. The fact that TestCache.aspx displays a
    > > SessionID makes me think
    > > that the Session has been created, but the Session variables just
    haven't
    > > been written. Without seeing
    > > the code that is actually writing the Session variables, I can't say for
    > > sure, but is it possible that there is some
    > > conditional condition not being satisfied on the initial run (something
    > like
    > > Page.IsPostBack maybe?) that is keeping the session
    > > variables from being written?
    > >
    > > Hope this helps.
    > >
    > > Jeff Trotman
    > > Westglenn Software
    > >
    > >
    > >
    > > "BGS" <bgs@_NOSPAM_msn.com> wrote in message
    > > news:vhbkkr174akeba@corp.supernews.com...
    > > > I am having a maddening problem with my web site. The pages generally
    > > > consist of an ASP page, in which there is an inline frame (<iframe>)
    > that
    > > > contains a "slide show" of photos. This inline frame holds an ASPX
    > page,
    > > > with code behind written in C#. The ASPX page relies on the Session
    > > Object
    > > > to hold information about which slide show is being viewed and which
    > photo
    > > > is current (so the "next", "previous" and "beginning" buttons will
    know
    > > > where to go in the sequence).
    > > >
    > > > All of this works perfectly, EXCEPT --
    > > >
    > > > When the user FIRST comes to one of the pages with this inline frame,
    > for
    > > > some reason ASP.NET often does not create the Session Object. The
    first
    > > > photo loads normally, but when the user clicks on the "next" button,
    an
    > > > error (usually a Session Out error) occurs (and the user is taken to a
    > > > custom error page). If the user clicks the "Refresh" ("Reload")
    button
    > on
    > > > the browser, the whole page (including the inline frame) reloads and
    > > > everything then proceeds as desired. In fact, when the user first
    comes
    > > to
    > > > the site, if he/she causes even just the inline frame to reload (by
    > > > right-clicking in the frame), the Session Object will be created and
    > > > everything proceeds as desired.
    > > >
    > > > To see this in action go to:
    > [url]http://www.on-the-matrix.com/africa/index.asp[/url]
    > > > (this is one of many pages with the inline frame slide show).
    > > >
    > > > To confirm that nothing is written to the Session Object, go to:
    > > > [url]http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx[/url] (which
    > lists
    > > > all cookies and the contents of the Session Object).
    > > >
    > > > Further information:
    > > >
    > > > 1. Both the ASP page and the ASPX page that loads in the inline frame
    > > > validate (as per [url]http://validator.w3.org/detailed.html[/url]). The ASP page
    > is
    > > > HTML 4.01 Transitional and the inline ASPX page is XHTML 1.0
    > Transitional.
    > > >
    > > > 2. There are no JavaScript errors (according to Mozilla's console) as
    I
    > > move
    > > > through the photos or go from page to page.
    > > >
    > > > 3. In the .NET code behind, it appears as if the Session Object is
    being
    > > > created. If I test in the code behind to see if Session.Count > 0, it
    > > comes
    > > > back true. Yet if I go to the test page listed above, Session.Count
    > comes
    > > > back as 0. (By the way, I am using the "InProc" mode of maintaining
    > > session
    > > > state with cookies.)
    > > >
    > > > 4. I tried having the ASP page write a cookie (called "StartCookie")
    the
    > > > first time any page was loaded. The inline ASPX page, through
    > JavaScript,
    > > > read this cookie and if it was the first time the page was loaded,
    > > > JavaScript would cause a "location.reload(true)" that would reload the
    > > > inline ASPX page. This caused some annoying double flashing of the
    > photo,
    > > > but otherwise worked perfectly on my home system and the Session
    Object
    > > was
    > > > always created when the ASPX page reloaded. For some reason, however,
    > the
    > > > StartCookie does not get written on my host server.
    > > >
    > > > 5. I can tell from my web stats that it is not just my browsers (IE
    and
    > > > Mozilla) that are causing the problem. Many visitors experience the
    > > problem
    > > > and it occurs with both IE, Mozilla and recent versions of Netscape
    > (older
    > > > versions get a page without the inline frame).
    > > >
    > > > 6. Both the ASP page and the inline ASPX photo page are created from
    XML
    > > > data transformed on the server using XSL stylesheets. Again, as
    noted,
    > > all
    > > > the resulting HTML validates.
    > > >
    > > > 7. By the way, I am NOT trying to access a Session Object created in
    ASP
    > > > with an ASPX page (I already learned that one). The ASPX page both
    > > creates
    > > > the Session Object and reads it.
    > > >
    > > > 8. As noted, once users get past the first page, everything works as
    > > > intended. It is only when the user FIRST comes to a page with a slide
    > > show
    > > > that the Session Object is not created.
    > > >
    > > > I hope somebody has some ideas. This is driving me absolutely NUTS!
    > > >
    > > > All help greatly appreciated,
    > > > Bruce
    > > >
    > > >
    > >
    > >
    >
    >

    Jeff Trotman 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