Losing Session State

W

Werner

Hi Patrick!

Can you give an example of how to use a frameset inside an aspx-file?
When I create a new frameset in Visual Studio.Net it just gives me a htm-File.

Or give me a link where I can find one?

Thanks
Werner
P.S. Somehow I did not manage to do a followup in Googles newsgroups.
Just curious. Why do you need an HTML frameset? Can't you simple use an
ASPX page as the frameset page?

John Moss said:
Thanks Patrick, I eventually figured it was something like
that. My way around it was to have a single aspx page load
first that points to the HTML frameset, this sets a
session id as well. In the particular example I'm working
on that's what will happen anyway, I was just in a
submodule when I got the problem.

Cheers
John
-----Original Message-----
The reason is that your frameset page is an HTM file instead of an ASPX
file. I will explain.

In normal case, if the frameset is an aspx file, when you request the page,
it will first send the request to the web server, receive an asp.net session
cookie (which holds the session id), and then the browser will send 3
individual requests for the frames, and each request will carry the same
session id.

However, since your frameset page is an htm file, the first request comes
back without any session cookie because the page was serviced by ASP and not
asp.net, and then your browser sends out 3 individual requests for each
frame. But this time each individual request will NOT carry any session id,
and so each individual frame will create its own new session. That's why
you will see 3 different session ids. The last request that comes back will
win by overwriting the cookie written by the previous two requests. If you
do a refresh, you will see them having the same session id.

This behaviour is by-design, and the simple solution is to change your
frameset page to .aspx.

But thanks for pointing this scenario out.

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

John Moss said:
I've attached a Zip file, I hope that's ok. What it
contains is all the files from a demo frameset I set up. I
also included a text file of version and system info, a
screen grab of the trace output and the pages from that
screen grab saved as htm files.

As you can see from the screen grab, each page in the
frameset has a different Session Id. This doesn't always
happen, sometimes (rarely) it's fine, usually the trace
details are missing from one of the frames so I can't tell
if all three Id's are different.

If there's any additional info I can give please let me
know
Cheers
John
-----Original Message-----
Assuming your app is using cookie to store the session id, then once a
session id is created and stored in your browser (i.e. you have stored
something in session, or Session_Start exists in global.asax), it won't go
away and you shouldn't have a changing session id.

The only possible scenarios for what you see are:
1. Your browser has lost the session cookie.
2. There is a BIG bug in ASP.NET which causes it to remove the session
cookie for you. (unlikely, as it's a very basic feature which is covered by
the basic test cases)

I do want to investigate the problem. Since you said it's very easy to
repro, is it possible for you to create (and post) a simple page with frames
that can demo the problem?

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

Well as I said I'm new to this, coming from a ColdFusion
background. At the moment I'm just setting a dummy message
so in the Page_Load (C#) of the initiating frame I'm using;
Session.Contents["Message"] = "Hello This Is A Session
Variable";

Then in the Page_Load of the action page I do a;
Response.Write("Session: " + Session.Contents
["Message"].ToString() + "<br>");

Like I said it was working before, but now works very
infrequently and it appears to be because the Session Id
is changing between page loads.

Obviously I will be wanting to use this sort of thing for
setting user ids etc.

This may be dumb, but do I have to actually turn the
Session on? I noticed in the link you sent mention of
Session.Clear and Session.Abandon...is there a
Session.Start? I haven't seen mention of it in the books I
have, though they didn't mention abandon or clear either.
Cheers
John
-----Original Message-----
Are you storing anything in the session in your app? Please read this FAQ
and see if it answers your problem:
http://www.asp.net/Forums/ShowPost.aspx? tabindex=1&PostID=7504

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

I'm writing my first ASP.Net application so forgive me if
this is a simple error. I am trying to set a value in a
session variable and was successfully doing this prior to
applying the latest .Net Service Pack. Now however the
Session Id is frequently lost when navigating pages.

The application starts in a frameset and the variable is
set in one of the three windows. When the form in this
window is submitted the frameset is replaced by a single
page where I try to display the Session variable. By
turning on tracing I have found that 7 times out of 10 the
Session Id is changing and therefore the value I have set
is no longer declared. I have tried both InProc and
SQLServer session management and get the same problem. Any
help would be gratefully accepted.


.



.


.



©2004 Go
 
A

Alvin Bruney [MVP]

Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Werner said:
Hi Patrick!

Can you give an example of how to use a frameset inside an aspx-file?
When I create a new frameset in Visual Studio.Net it just gives me a htm-File.

Or give me a link where I can find one?

Thanks
Werner
P.S. Somehow I did not manage to do a followup in Googles newsgroups.
Just curious. Why do you need an HTML frameset? Can't you simple use an
ASPX page as the frameset page?
rights.

John Moss said:
Thanks Patrick, I eventually figured it was something like
that. My way around it was to have a single aspx page load
first that points to the HTML frameset, this sets a
session id as well. In the particular example I'm working
on that's what will happen anyway, I was just in a
submodule when I got the problem.

Cheers
John
-----Original Message-----
The reason is that your frameset page is an HTM file instead of an ASPX
file. I will explain.

In normal case, if the frameset is an aspx file, when you request the page,
it will first send the request to the web server, receive an asp.net session
cookie (which holds the session id), and then the browser will send 3
individual requests for the frames, and each request will carry the same
session id.

However, since your frameset page is an htm file, the first request comes
back without any session cookie because the page was serviced by ASP and not
asp.net, and then your browser sends out 3 individual requests for each
frame. But this time each individual request will NOT carry any session id,
and so each individual frame will create its own new session. That's why
you will see 3 different session ids. The last request that comes back will
win by overwriting the cookie written by the previous two requests. If you
do a refresh, you will see them having the same session id.

This behaviour is by-design, and the simple solution is to change your
frameset page to .aspx.

But thanks for pointing this scenario out.

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

I've attached a Zip file, I hope that's ok. What it
contains is all the files from a demo frameset I set up. I
also included a text file of version and system info, a
screen grab of the trace output and the pages from that
screen grab saved as htm files.

As you can see from the screen grab, each page in the
frameset has a different Session Id. This doesn't always
happen, sometimes (rarely) it's fine, usually the trace
details are missing from one of the frames so I can't tell
if all three Id's are different.

If there's any additional info I can give please let me
know
Cheers
John
-----Original Message-----
Assuming your app is using cookie to store the session id, then once a
session id is created and stored in your browser (i.e. you have stored
something in session, or Session_Start exists in global.asax), it won't go
away and you shouldn't have a changing session id.

The only possible scenarios for what you see are:
1. Your browser has lost the session cookie.
2. There is a BIG bug in ASP.NET which causes it to remove the session
cookie for you. (unlikely, as it's a very basic feature which is covered by
the basic test cases)

I do want to investigate the problem. Since you said it's very easy to
repro, is it possible for you to create (and post) a simple page with frames
that can demo the problem?

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

Well as I said I'm new to this, coming from a ColdFusion
background. At the moment I'm just setting a dummy message
so in the Page_Load (C#) of the initiating frame I'm using;
Session.Contents["Message"] = "Hello This Is A Session
Variable";

Then in the Page_Load of the action page I do a;
Response.Write("Session: " + Session.Contents
["Message"].ToString() + "<br>");

Like I said it was working before, but now works very
infrequently and it appears to be because the Session Id
is changing between page loads.

Obviously I will be wanting to use this sort of thing for
setting user ids etc.

This may be dumb, but do I have to actually turn the
Session on? I noticed in the link you sent mention of
Session.Clear and Session.Abandon...is there a
Session.Start? I haven't seen mention of it in the books I
have, though they didn't mention abandon or clear either.
Cheers
John
-----Original Message-----
Are you storing anything in the session in your app? Please read this FAQ
and see if it answers your problem:
http://www.asp.net/Forums/ShowPost.aspx? tabindex=1&PostID=7504

--
Patrick Y. Ng
(ASP.NET Team)
This posting is provided "AS IS" with no warranties, and confers no rights.

I'm writing my first ASP.Net application so forgive me if
this is a simple error. I am trying to set a value in a
session variable and was successfully doing this prior to
applying the latest .Net Service Pack. Now however the
Session Id is frequently lost when navigating pages.

The application starts in a frameset and the variable is
set in one of the three windows. When the form in this
window is submitted the frameset is replaced by a single
page where I try to display the Session variable. By
turning on tracing I have found that 7 times out of 10 the
Session Id is changing and therefore the value I have set
is no longer declared. I have tried both InProc and
SQLServer session management and get the same problem. Any
help would be gratefully accepted.


.



.



.



©2004 Go
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top