Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Session Object Craziness

Reply
Thread Tools

Re: Session Object Craziness

 
 
Jeff Trotman
Guest
Posts: n/a
 
      07-17-2003
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:(E-Mail Removed)...
> 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/...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
>
>



 
Reply With Quote
 
 
 
 
BGS
Guest
Posts: n/a
 
      07-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:(E-Mail Removed)...
> > 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/...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
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Jeff Trotman
Guest
Posts: n/a
 
      07-18-2003
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:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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:(E-Mail Removed)...
> > > 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/...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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static Variables and Craziness dougloj ASP .Net 5 01-06-2007 06:47 AM
managed and native craziness Mike Kamzyuk C++ 2 04-26-2005 08:42 PM
Namespace Craziness Martin c ASP .Net 3 02-13-2004 12:38 AM
Zone Alarm craziness Dogg NZ Computing 7 12-03-2003 11:40 PM
"Special edition" craziness Grand Inquisitor DVD Video 13 11-21-2003 02:52 AM



Advertisments