asp.net - Detect session timeout after Response.Redirect? -


i implementing log-in/log-out functionality on website. whenever user clicks on sign out button (anywhere @ login page, login.aspx), following method execute:

protected void signout(object sender, eventargs e) {     session.abandon();     response.redirect("login.aspx"); } 

now, when redirect happens, want following in login.aspx:

protected void page_init(object sender, eventargs e) {     if ( session_has_timed_out ... )         sessiontimeoutdiv.text = "session timed out. please log in again.";     else     {         // normal logic here ...     } } 

q: how check session terminated, given need check (1) after actual call session.abandon() , (2) after redirected call session.abandon() had happened?

yes that's why authentication recommended rely on cookie , use formsauth or asp.net identity. if mvc have tempdata webforms don't think there such thing. can use other state management techniques query string

response.redirect("login.aspx?logout=true"); 

in page_init of login.aspx

    if (request.querystring["logout"] != null && request.querystring["logout"] == "true") //do handle exception , casting     {         //sessiontimeoutdiv.text = "session timed out. please log in again.";     }     else     {         // normal logic here ...     } 

this hack, hope helps.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -