locked
browser back and document expired message RRS feed

  • Question

  • User766547310 posted

    hi all,

    i have used below code in master page load event to mange the back button once the user log out of  page using asp.net membership.

    Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetNoStore();


    Now if the user click the back button it get document expired , the document This document is no longer available message in firefox, and error in chrome.

    and the user need to refresh the page.

    how can i redirect the user to another page in case it click the back button and the user is already log out, so the user don't see this error message.

    asp.net forum used similar approach and redirect to another page by using timer.

    thanks

    Friday, April 25, 2014 1:36 PM

Answers

  • User281315223 posted

    You really typically don't want to attempt to alter the default behavior involved with the browser's back button (as this is purely client-side and specific to the browser). You should consider adding some form of authentication to your application like Forms Authentication which will allow your users to login and then you can add the necessary security within your application to ensure that only authenticated users can access specific areas.

    Forms Authentication basically will create a browser cookie (Authentication Token) when your user logs in and this will be used to signify that the user has authenticated in your application. When you want the user to log out, you can simply call the FormsAuthentication.SignOut() method :

    FormsAuthentication.SignOut();

    When you combine requiring this authentication in your pages along with removing the cache, this will ensure that when the back button is pressed after a user logs out, that they will be forced to log back in.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 25, 2014 2:09 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 25, 2014 2:30 PM
  • User766547310 posted

    excellent post by frez , by using timer in log out page , clearing the cache and then redirecting user to mainpage or login page.

    http://geekswithblogs.net/Frez/articles/back-button-issue-after-logout-in-asp.net.aspx

    hope it will help some one else.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 26, 2014 11:07 AM

All replies

  • User724169276 posted

    Hello,

    Dont clear the cache .. let the end user go back .. on every page pageload check the session for logged in users .. if the session is not null then he/she is already logged in .. then redirect them back to home page .

    Friday, April 25, 2014 1:59 PM
  • User766547310 posted
    Hi as him,
    Thanks for your reply , I am not using session in my application . Any other solution , the user can go back by using above code only when he log out and click the back button then that message will appear I need to either redirect the user to another page or show a proper user friendly message .

    Thanks
    Friday, April 25, 2014 2:05 PM
  • User724169276 posted

    if you are not using sessions for maintaining logins then what kind of authentication here we are dealing with ?? Morover you cant control the browser back button , plus its an annoying thing for an end user to restrict the back button.

    Friday, April 25, 2014 2:09 PM
  • User281315223 posted

    You really typically don't want to attempt to alter the default behavior involved with the browser's back button (as this is purely client-side and specific to the browser). You should consider adding some form of authentication to your application like Forms Authentication which will allow your users to login and then you can add the necessary security within your application to ensure that only authenticated users can access specific areas.

    Forms Authentication basically will create a browser cookie (Authentication Token) when your user logs in and this will be used to signify that the user has authenticated in your application. When you want the user to log out, you can simply call the FormsAuthentication.SignOut() method :

    FormsAuthentication.SignOut();

    When you combine requiring this authentication in your pages along with removing the cache, this will ensure that when the back button is pressed after a user logs out, that they will be forced to log back in.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 25, 2014 2:09 PM
  • User766547310 posted
    Thanks rion for your reply I am using form authentication and sign out method of it on log out button click .

    In my page I use two master page for two languages and this is couzing problem

    1. When I log in by default page1 which use first master page loads now if I click the sign out and then click back button it will not take me to authenticated page which work perfectly but the problem is

    2. After log in if I click page2 which use second master page and then click the sign out it and click the back button it will again take me to authenticated page and menu that need to be displayed for authentic user is viewed.

    Any other solution guys.
    Friday, April 25, 2014 2:27 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 25, 2014 2:30 PM
  • User766547310 posted

    Thanks but disabling back button create in inconvenience for users I have already tried those solutions<br>
    Friday, April 25, 2014 2:44 PM
  • User766547310 posted

    excellent post by frez , by using timer in log out page , clearing the cache and then redirecting user to mainpage or login page.

    http://geekswithblogs.net/Frez/articles/back-button-issue-after-logout-in-asp.net.aspx

    hope it will help some one else.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 26, 2014 11:07 AM