Session loses all variables during Response.Redirect

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: Session loses all variables during Response.Redirect

    Hi,

    Just a hint. If you change anything in the Bin directory of the
    application the application will be restart and all the session data
    will be lost. Are you writing lo a log file on the Bin directory when
    some conditions come true?


    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  2. Similar Questions and Discussions

    1. [SOLVED] Session loses all variables during Response.Redirect
      Ok, don't ask me why, but this solved it: Replace the line: Directory.Move(tempEventDirName, createdEventDirName); With:...
    2. After redirect back from 3rd party, session variables lost
      Thank you in advance. My ASP page 1 redirect user to third party's website, after the process at third party is finished, in 3rd party's...
    3. Adding variables to response.redirect
      I have a page that contains processed variables that I'd like to forward using the response.redirect method. However, because the response.redirect...
    4. PLEASE - Session Variables OR Response.Write querystring to target frame?
      Hi, I'm doing an asp.net app (first one) and NEED to use frames (so please don't tell me not to!). I'm loading a mainframe.htm with two aspx files...
    5. Redirect to New Browser Window like Response.Redirect
      That worked just fine for me as long as you put that open statement on one line rather than 2. "michel" <michely3k@yahoo.com> wrote in...
  3. #2

    Default Re: Session loses all variables during Response.Redirect

    Session management in .NET is very very buggy. I am not sure how Microsoft
    shipped .NET with such implementation. There are many reasons (and bugs)
    that causes the session to get lost in .NET.

    aspnet_wp.exe gets recycled due to lack of memory (which is caused by the
    way .Net handles releasing objects from memory) and that removes all stored
    sessions for all users. Work around for this is to use StateServer or SQL
    Server session management.

    Session variables stored in a certain page are not maintained when
    redirecting to another page. This I've seen in .NET 2002 but have not tried
    to duplicate it in .NET 2003 caused by a bug in .NET. Solution was to
    basically delete that page and redo it. If you copy and paste the same code
    of the original page it works fine. just got to get rid of the firt page.

    Session variables not maintained when redirecting in debug mode. I started
    to get this after installing SP2 for .NET 2002. Solution is either not run
    in debug mode, or open a browser window before debugging, start debugger
    (ignore the browser window opened by the debugger) and test the window you
    manually opened.

    Thats my experience with the session objects. Your problem does not really
    reflect any of the above but worth a shot. Also there might be a size limit,
    how big is the image?

    fadi

    "Mark MacRae" <nospam@nospam.com> wrote in message
    news:#lrqqF6SDHA.1920@TK2MSFTNGP11.phx.gbl...
    > I have searched the newsgroups for this and found a couple of similar
    > situations, but none solved my problem.
    >
    > Basically the click of a button on one webform saves an entity then
    > Response.Redirects back to a list page which lists all the entities in the
    > database belonging to the user who is currently logged in.
    >
    > This works fine most of the time. Except when you use the option to upload
    a
    > new image as part of the entity. I'm not entirely sure that that is
    > relevant though because I have stepped through the code in debug mode and
    > the Session still contains 10 variables right up until end of the save
    > button click event code which is the Response.Redirect
    >
    > When I reach the first line of the Page_Load event on the listing page,
    the
    > Session has lost all of it's variables. Poof! Gone! Why? Is there a
    step
    > in between that I don't know about?
    >
    > I have seen responses that mention that both ASPX pages must be in the
    same
    > project, well they are. And in fact, as I mentioned, the session does not
    > lose the variables most times. Only when a new image is uploaded. Below
    is
    > the chunk of code that is different in that case:
    >
    >
    > if(model.imagePath_NullableString != null) {
    > string tempEventDirName = (string)Context.Session["tempDir"];
    >
    > if(tempEventDirName != null && tempEventDirName != string.Empty &&
    > tempEventDirName != "") {
    >
    > string createdEventDirName =
    Context.Request.PhysicalApplicationPath
    > + "/images/listing_files/" + model.pk;
    >
    > Directory.Move(tempEventDirName, createdEventDirName);
    >
    > }
    >
    > }
    >
    >

    fadi Guest

  4. #3

    Default Re: Session loses all variables during Response.Redirect

    Thanks for the ideas.
    I limit the size of the image to under 20K.

    "fadi" <fadiz@nospam.com> wrote in message
    news:e9yiXIWTDHA.3700@tk2msftngp13.phx.gbl...
    > Session management in .NET is very very buggy. I am not sure how Microsoft
    > shipped .NET with such implementation. There are many reasons (and bugs)
    > that causes the session to get lost in .NET.
    >
    > aspnet_wp.exe gets recycled due to lack of memory (which is caused by the
    > way .Net handles releasing objects from memory) and that removes all
    stored
    > sessions for all users. Work around for this is to use StateServer or SQL
    > Server session management.
    >
    > Session variables stored in a certain page are not maintained when
    > redirecting to another page. This I've seen in .NET 2002 but have not
    tried
    > to duplicate it in .NET 2003 caused by a bug in .NET. Solution was to
    > basically delete that page and redo it. If you copy and paste the same
    code
    > of the original page it works fine. just got to get rid of the firt page.
    >
    > Session variables not maintained when redirecting in debug mode. I started
    > to get this after installing SP2 for .NET 2002. Solution is either not run
    > in debug mode, or open a browser window before debugging, start debugger
    > (ignore the browser window opened by the debugger) and test the window you
    > manually opened.
    >
    > Thats my experience with the session objects. Your problem does not really
    > reflect any of the above but worth a shot. Also there might be a size
    limit,
    > how big is the image?
    >
    > fadi
    >
    > "Mark MacRae" <nospam@nospam.com> wrote in message
    > news:#lrqqF6SDHA.1920@TK2MSFTNGP11.phx.gbl...
    > > I have searched the newsgroups for this and found a couple of similar
    > > situations, but none solved my problem.
    > >
    > > Basically the click of a button on one webform saves an entity then
    > > Response.Redirects back to a list page which lists all the entities in
    the
    > > database belonging to the user who is currently logged in.
    > >
    > > This works fine most of the time. Except when you use the option to
    upload
    > a
    > > new image as part of the entity. I'm not entirely sure that that is
    > > relevant though because I have stepped through the code in debug mode
    and
    > > the Session still contains 10 variables right up until end of the save
    > > button click event code which is the Response.Redirect
    > >
    > > When I reach the first line of the Page_Load event on the listing page,
    > the
    > > Session has lost all of it's variables. Poof! Gone! Why? Is there a
    > step
    > > in between that I don't know about?
    > >
    > > I have seen responses that mention that both ASPX pages must be in the
    > same
    > > project, well they are. And in fact, as I mentioned, the session does
    not
    > > lose the variables most times. Only when a new image is uploaded.
    Below
    > is
    > > the chunk of code that is different in that case:
    > >
    > >
    > > if(model.imagePath_NullableString != null) {
    > > string tempEventDirName = (string)Context.Session["tempDir"];
    > >
    > > if(tempEventDirName != null && tempEventDirName != string.Empty &&
    > > tempEventDirName != "") {
    > >
    > > string createdEventDirName =
    > Context.Request.PhysicalApplicationPath
    > > + "/images/listing_files/" + model.pk;
    > >
    > > Directory.Move(tempEventDirName, createdEventDirName);
    > >
    > > }
    > >
    > > }
    > >
    > >
    >
    >

    Mark MacRae Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139