Re: Session Object Craziness

Discussion in 'ASP .Net' started by Jeff Trotman, Jul 17, 2003.

  1. Jeff Trotman

    Jeff Trotman Guest

    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:...
    > 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: http://www.on-the-matrix.com/africa/index.asp
    > (this is one of many pages with the inline frame slide show).
    >
    > To confirm that nothing is written to the Session Object, go to:
    > http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx (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 http://validator.w3.org/detailed.html). 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, Jul 17, 2003
    #1
    1. Advertising

  2. Jeff Trotman

    BGS Guest

    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" <> wrote in message
    news:...
    > 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:...
    > > 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:

    http://www.on-the-matrix.com/africa/index.asp
    > > (this is one of many pages with the inline frame slide show).
    > >
    > > To confirm that nothing is written to the Session Object, go to:
    > > http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx (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 http://validator.w3.org/detailed.html). 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, Jul 17, 2003
    #2
    1. Advertising

  3. Jeff Trotman

    Jeff Trotman Guest

    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:...
    > 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" <> wrote in message
    > news:...
    > > 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:...
    > > > 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:

    > http://www.on-the-matrix.com/africa/index.asp
    > > > (this is one of many pages with the inline frame slide show).
    > > >
    > > > To confirm that nothing is written to the Session Object, go to:
    > > > http://www.on-the-matrix.com/shared/slidepages/TestCache.aspx (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 http://validator.w3.org/detailed.html). 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, Jul 18, 2003
    #3
    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. Martin c

    Namespace Craziness

    Martin c, Feb 10, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    580
    Steven Cheng[MSFT]
    Feb 13, 2004
  2. Mike Kamzyuk

    managed and native craziness

    Mike Kamzyuk, Apr 26, 2005, in forum: C++
    Replies:
    2
    Views:
    322
    Mike Kamzyuk
    Apr 26, 2005
  3. dougloj

    Static Variables and Craziness

    dougloj, Jan 5, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    394
    dougloj
    Jan 6, 2007
  4. Sideswipe

    Delegation and generics craziness

    Sideswipe, Aug 11, 2008, in forum: Java
    Replies:
    9
    Views:
    399
    Daniel Pitts
    Oct 4, 2008
  5. Unknown Poster

    Copy Constructor Craziness

    Unknown Poster, Feb 4, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    150
    Jay Tilton
    Feb 9, 2004
Loading...

Share This Page