views:

680

answers:

4

I want that after Logging Out any user should not be able to go to the Back Page. How can i do that?

A: 

AFAIK, you can not disable back button of web browser.

Add the following

"if user is logged in"

<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>
Ratnesh Maurya
Suppose i am in a page and i have clicked the logout Button, then it is taking me to Login Page.But if i am Clicking the Back button then it is Displaying me the previous page and its value .How to stop that ?
as answered by Canavar, clear cache. Add no cache header. Edited my post.
Ratnesh Maurya
+2  A: 

Clear the cache instead, it's more reliable.

Add these to your header section of the page :

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">

And add this to your page load :

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Canavar
It is not working :(
Similar to this, add a no-cache header to the output of your pages that you don't want the user going back to.
womp
Yes, I just mean it :)
Canavar
A: 

You could try setting no-cache on the pages viewed by authenticated users, that should requier the users browser to reload the page from the server.

Fredrik Leijon
Clicking the Back Button it is not doing a PageLoad. So how to do anything ?
A: 

Disabling the back button is not possible, perfectly. So you can:

  1. Close the window on Log off.
  2. On each page, check for a valid session and if not found, redirect to login page.
danish
1. bad solution2. will not work for back button as browser does not does a post back on back button.
Ratnesh Maurya
@rats. you are mostly right, but in my experience, safari makes a fresh request on back
Midhat
i am not sure about safari, but IE, FF and Opera does not do a post back unless you ask them not to cache. :-)
Ratnesh Maurya