Losing Session State

Discussion in 'ASP .Net' started by Werner, Feb 20, 2004.

  1. Werner

    Werner Guest

    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?


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


    "John Moss" <> wrote in message
    news:b0f401c2906e$b1921b60$89f82ecf@TK2MSFTNGXA01...
    > 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" <> wrote in message
    > >news:80e301c28f94$1b47fe70$89f82ecf@TK2MSFTNGXA01...
    > >> 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.
    > >> >
    > >> >"John Moss" <> wrote in message
    > >> >news:0cb601c28c51$e4fc6120$8df82ecf@TK2MSFTNGXA02...
    > >> >> 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.
    > >> >> >
    > >> >> >"John Moss" <> wrote in message
    > >> >> >news:0a5d01c28c46$ec0e6180$89f82ecf@TK2MSFTNGXA01...
    > >> >> >> 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
     
    Werner, Feb 20, 2004
    #1
    1. Advertising

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

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

    rights.
    >
    > "John Moss" <> wrote in message
    > news:b0f401c2906e$b1921b60$89f82ecf@TK2MSFTNGXA01...
    > > 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" <> wrote in message
    > > >news:80e301c28f94$1b47fe70$89f82ecf@TK2MSFTNGXA01...
    > > >> 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.
    > > >> >
    > > >> >"John Moss" <> wrote in message
    > > >> >news:0cb601c28c51$e4fc6120$8df82ecf@TK2MSFTNGXA02...
    > > >> >> 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.
    > > >> >> >
    > > >> >> >"John Moss" <> wrote in message
    > > >> >> >news:0a5d01c28c46$ec0e6180$89f82ecf@TK2MSFTNGXA01...
    > > >> >> >> 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
     
    Alvin Bruney [MVP], Mar 2, 2004
    #2
    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. DalePres
    Replies:
    0
    Views:
    438
    DalePres
    Apr 28, 2004
  2. Keith-Earl
    Replies:
    4
    Views:
    591
    Keith-Earl
    May 3, 2004
  3. Keith-Earl
    Replies:
    1
    Views:
    420
    Alvin Bruney [MVP]
    May 3, 2004
  4. Vinay Joseph Mathew

    Losing Session State on a State Server

    Vinay Joseph Mathew, Aug 10, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    612
    =?Utf-8?B?c29ubnk=?=
    Sep 16, 2004
  5. Jason C
    Replies:
    4
    Views:
    696
    Morty Abzug
    Jun 26, 2012
Loading...

Share This Page