locked
PagePostback is false after session expire RRS feed

  • Question

  • Hi,

    I have a page where we check for

    If (Page.IsPostBack)

      If(Session.IsNewSession)

          <!-- Do Something -->

      End If

    End If

    Session Time out is kept for 1 minute.

    When i first hit the page it works as expected, i.e. Page.IsPostBack comes as false and Session.IsNewSession as true.

    When i click any button over the page within one minute it works as expected i.e. Page.IsPostBack comes as true and Session.IsNewSession as false.

    But if we keep the page idle for 1 minute and then click any button on page (basically after session timeout), Page.IsPostBack still comes as false (which is against what i am expecting) and Session.IsNewSession as true.

    Can someody please explain this behaviour?

    • Moved by CoolDadTx Tuesday, October 27, 2015 5:08 PM Wrong forums
    Tuesday, October 27, 2015 12:43 PM

Answers

  • Please post asp.net questions on the asp.net official forum for a better assistance on your case. Also note that this a C# forum not VB.

    Fouad Roumieh

    • Proposed as answer by Christopher84 Tuesday, October 27, 2015 1:31 PM
    • Unproposed as answer by i.m.sassh Tuesday, October 27, 2015 2:43 PM
    • Proposed as answer by Just Karl Tuesday, October 27, 2015 8:22 PM
    • Marked as answer by Just Karl Thursday, November 5, 2015 11:30 PM
    Tuesday, October 27, 2015 1:18 PM

All replies

  • Please post asp.net questions on the asp.net official forum for a better assistance on your case. Also note that this a C# forum not VB.

    Fouad Roumieh

    • Proposed as answer by Christopher84 Tuesday, October 27, 2015 1:31 PM
    • Unproposed as answer by i.m.sassh Tuesday, October 27, 2015 2:43 PM
    • Proposed as answer by Just Karl Tuesday, October 27, 2015 8:22 PM
    • Marked as answer by Just Karl Thursday, November 5, 2015 11:30 PM
    Tuesday, October 27, 2015 1:18 PM
  • But if we keep the page idle for 1 minute and then click any button on page (basically after session timeout), Page.IsPostBack still comes as false (which is against what i am expecting) and Session.IsNewSession as true.

    What's the point, because the session is dead anyway and everything that was happening is lost, unless you were keeping things in state on the page by using hidden fields?

    http://forums.asp.net/

    Tuesday, October 27, 2015 1:39 PM
  • Redirect user to the session expire page / error page after session has expired, indicating that the session has expired and please login to the application or something like that.

    Can't change the functionality as it is legacy application.

    Tuesday, October 27, 2015 2:42 PM
  • Redirect user to the session expire page / error page after session has expired, indicating that the session has expired and please login to the application or something like that.

    If the session has timed out, all is lost and that's all you can do is make them sign back in again and start over.

    Tuesday, October 27, 2015 3:18 PM
  • There is no clear defintion of how Page.IsPostBack is set or defined. However the most likely way is that they check for a existing (still valid) session. If there is one, it is a postback. If not, then not.

    If there is no session present, there is rarely any point differentiating between "timed out just recently" and "has not been logged in for ages".

    Everytime I made a "your session timed out" tracking, I did that in the backend DB that store the sessions themself. And on timeout, I put set a flag in the User table.
    What is the backend you store the sessions in?

    Why is the session timeout set so wierdly (1 minute)?
    That is way to low for a user inputting stuff. Unless you do wierd stuff like a postback every input character or focus change (wich you should never do).
    1 minute would be suited for something filled out/transmitted automatically. But there is no sensical reason any automatic should ever automate a website. Any of the miriad ways to make a webservice would be better for this kind of automation.

    Tuesday, October 27, 2015 5:07 PM