Clicking back after sign out

Last post 05-20-2008 3:51 AM by Musafiir. 16 replies.

Sort Posts:

  • Clicking back after sign out

    05-17-2008, 1:55 AM
    • Loading...
    • Musafiir
    • Joined on 04-05-2008, 12:13 AM
    • Posts 50

    HI all ,

    There is a WEB application whereby after signout, the user is directed to the login page.

     FormsAuthentication.SignOut()

    FormsAuthentication.RedirectToLoginPage()

      

    But how to code the page such that when the user clicks back in the web browser, the page shows the login page

    and not the page after login?

     

    Thanks to all
     

  • Re: Clicking back after sign out

    05-17-2008, 4:07 AM
    • Loading...
    • Talib_dotnet
    • Joined on 01-31-2008, 11:02 AM
    • Riyadh , K.S.A
    • Posts 354

    Hi,

    In  that  page's  load event  , write something  as

    if (Session["UserID"]=="null")

    {

    Response.Redirect("Login.aspx"); 

    }

    else

    {

    ................ 

    }

     

    Hope  this helps  you.....

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    MCTS
    Welcome to TALIB's World



  • Re: Clicking back after sign out

    05-17-2008, 5:02 AM

    Hi

    talib is write you have to store a session(user_id)  at login page and at logout empty this session id . and check at every page

    if session("user_id")="" then

    response.redirect("login.aspx")

    end if

  • Re: Clicking back after sign out

    05-17-2008, 5:27 AM
    • Loading...
    • Musafiir
    • Joined on 04-05-2008, 12:13 AM
    • Posts 50

     Thank you for the reply.

    I used lblUsername.Text = Request.Form("txtUsername").ToString 

    I applied lblUsername.Text = "". But still when i click back it, it displays the login name [Username].

    I tried upon page load to implement the code, but it does not open the after login page.

    Any solution?

     

    Filed under:
  • Re: Clicking back after sign out

    05-17-2008, 5:33 AM
    • Loading...
    • Talib_dotnet
    • Joined on 01-31-2008, 11:02 AM
    • Riyadh , K.S.A
    • Posts 354

    Buddy,

    try using  what  i  have  suggested.......  and  let me  know  ......

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    MCTS
    Welcome to TALIB's World



  • Re: Clicking back after sign out

    05-17-2008, 8:05 AM
    • Loading...
    • Musafiir
    • Joined on 04-05-2008, 12:13 AM
    • Posts 50

    Thanks for your reply.

    I did tried it but didnt mention. The output was same, i.e i can navigate backward.

    Ws done exactly as said, upon page load event, the code for null session was entered. But still it shows logged in information

    which was not suppose to be.

    No confusion should be made about the BACKWARD process with LOGIN again process.  

    Any other method to solve this? 

  • Re: Clicking back after sign out

    05-17-2008, 8:12 AM
    • Loading...
    • Talib_dotnet
    • Joined on 01-31-2008, 11:02 AM
    • Riyadh , K.S.A
    • Posts 354

    Buddy,

    Try this  ,,,

    if (!Page.IsPostBack)

    {

    if (Session["UserId"] == "null")

    {

    Response.Redirect("Login.aspx")
    ;

    }

    else

    {

    ..........

    }

    }

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    MCTS
    Welcome to TALIB's World



  • Re: Clicking back after sign out

    05-17-2008, 8:31 AM
    • Loading...
    • Musafiir
    • Joined on 04-05-2008, 12:13 AM
    • Posts 50

    Thanks for your reply buddy,

    tried that also but still i can move BACKWARD and see my user name.

    I also tried, the Abandon, Clear, Remove functions from the session. But still i can move back.

    Any other alternative?
     

  • Re: Clicking back after sign out

    05-17-2008, 8:48 AM

    on log out try empty session like this

    session("user_id")=""

  • Re: Clicking back after sign out

    05-17-2008, 8:57 AM
    • Loading...
    • Talib_dotnet
    • Joined on 01-31-2008, 11:02 AM
    • Riyadh , K.S.A
    • Posts 354

    Try using  Request.QueryString["UserId"]   instead  of  Session["UserId"]..

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    MCTS
    Welcome to TALIB's World



  • Re: Clicking back after sign out

    05-17-2008, 8:57 AM

    send your code on click of logout

  • Re: Clicking back after sign out

    05-17-2008, 9:23 AM
    • Loading...
    • Talib_dotnet
    • Joined on 01-31-2008, 11:02 AM
    • Riyadh , K.S.A
    • Posts 354

    Hi,

    try this code  .  i have  tested  it 

    if (Convert.ToString(Request.QueryString["Id"]) == null)

    {

    Response.Redirect(
    "Login.aspx");

    }

    else

    {

    ............. 

    }

     

     

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    MCTS
    Welcome to TALIB's World



  • Re: Clicking back after sign out

    05-17-2008, 9:54 AM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 8:31 AM
    • Jerusalem
    • Posts 4,067

    I think the problem is not in the code, its a browser caching issue ,

    your pages are being cached on the client browser ! you need to disable this behavior by adding the following line to yur pages load  

    Response.Cache.SetCacheability(HttpCacheability.NoCache)

     

    Best Regards,

    Anas Ghanem| LogFile
  • Re: Clicking back after sign out

    05-17-2008, 11:33 AM
    • Loading...
    • Musafiir
    • Joined on 04-05-2008, 12:13 AM
    • Posts 50

    Thanks for your reply.

     I tested it with both :-

      lblUsername.Text = Request.Form("txtUsername").ToString

    lblUsername.Text = Session("username")
     

    Also cleared the session upon logout. i added session.Abandon/clear/remove too

    And lastly the  

    Response.Cache.SetCacheability(HttpCacheability.NoCache)

    Still i can move backward. It its some cache, it should be cleared but when i used with with IExplorer, without remembering password,  

    it still moves back. 

    The log out code is simple :

     

           FormsAuthentication.SignOut()
    Session("username") = ""
    'Session.Abandon()
            FormsAuthentication.RedirectToLoginPage()
     
     I read other posts also, upon session.abandon, the session should be destroyed but there it isnt.
     
  • Re: Clicking back after sign out

    05-19-2008, 12:30 PM
    Answer
    • Loading...
    • bryce27
    • Joined on 08-16-2007, 10:32 PM
    • Posts 4
    In your page_load event add :

    Response.Cache.SetNoStore()

    This way the page is not stored in the users cache, so when the user logs out from that page there is no stored page to navigate back to.

     

Page 1 of 2 (17 items) 1 2 Next >