Frames and Session?

K

Kent Tegels

Okay, so I know I'm doing two evil things: using Frames
and storing stuff in Session. I'm a sinner and I'll
repent after this project, I promise.

But for now, I've got an interesting issue.

In a site's Gobal.asax, I've written the following in
Session_OnStart:

Session.Add("Started",now.toString)

I also have a WebForm named WebForm1.aspx (not feeling
overly creative today) where, in the PageLoad event, I've
added this:

Session.Add("PageLoad",now.toString)

Using Performance Monitor, I've watch the total of active
sessions when browsing WebForm1 .aspx. As expected, I get
use on (additional) session.

This site also has a frameset page in it (frameset1.htm)
and "contains" three webforms: Frame1.aspx, Frame2.aspx
and Frame3.aspx. Each of the /Frame\d.aspx/ files as
statement like the following in its PageLoad
event:

(note that /Frame\d.aspx/ is one of
frame1.aspx...frame3.aspx, I'm just used tro writing
Regular Expressions...)

Session.Add("Frame/\d/",now.toString)

Before browsing Frameset1.htm, I use IIS restart to
abadon and clean out all sessions. But when I browse
Frameset1.htm, I get not one, not two, but three active
sessions. Each of the Frame\d.aspx pages has label
controls that show the SessionID, the global "Started"
and local "Frame/\d/" value.

That begs three questions:
a. Why?
b. If I just want one session for all three frames, what
do I need to do?
c. Is this new behavior 1.1 or does it has it never
worked like I thought it would? (e.g, this is behavior by
design)

FWIW, I've also tried decorating the code
with "SyncBlock"s in the Frame/\d/.aspx pages, but it
doesn't seem to make a difference.

I think I have a partial answer: each frame is getting
its own session ID. I don't want that, I want them all to
have the same one.

BTW, I get the same results with fx1.0, but not with
fx1.2 (Whidbey... heh, something that does work there...)

Thanks,

Kent Tegels
 
K

Kevin Spencer

Using Frames and Session is not "evil" - it is merely difficult, and
requires a good bit more programming skill to do than to work without either
one. Session State is, in fact, still quite useful, and even necessary from
one time to another. You have just encountered what makes using Frames
difficult. You see, a FrameSet is a container that holds multiple instances
of a browser in a single HTML document. Because each Frame is a separate
instance of the browser, each Frame has its own Session. There is no way to
share the Session between them. In fact, the only communication that can
occur between them is on the client side, via JavaScript and/or hyperlinks.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
K

Kent Tegels

Kevin,

Thanks for the response. While I think the answer you
gave is correct, I'm getting some very different behavior
that begs a couple of questions.

a. Subsequent testing has shown that this is only a
problem for the first browse after the site has been
compiled. Any subsequent sessions appear to have the same
session IDs and session values for each frame. That would
run counter to the behavior you've described.

b. Why isn't this occuring with Whidbey? Did they change
the Session ID generation mechanism maybe? Is there some
lucky charm in the code that we better not count on?

Since we're fairly early in the process, changing the
site to be unframed isn't that painful to do. I'm more or
less wondering why (techically) we're getting the
experience we are.

If I'm making sense, I'll gladly put the source code
where you can get at it if you like.

Thanks!
kt
 
K

Kevin Spencer

You will find that this behavior changes from one browser to another, from
one version of a browser to another, and from one environment to another. As
I never use Frames, I'm afraid you're on your own if you want to pursue this
avenue.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top