How to prevent user viewing previous page?

cait

Newcomer
Joined
Apr 6, 2004
Messages
1
Hi,

I have developed an application in ASP. NET that has some pages along with login and logout pages/links.After a user logsout from this application,he is still able to view previous pages by using back button in the browser.

Am using sessions to check in each page,whether the user is valid .Am emptying sessions variables and abandon session too when he logs out of the application.Still,he is able to view previous pages because they are displayed from browser's cache.

I want my user to be redirected to my homepage/login page if tries to view previous page using browser's back button,once he has logout of the application.

How to do this in asp.net (am using vb.net as code behind)

Thanks and regards
cait
 
This can't be done on the Server-side. (If yes I don't know how)
But it can easily be done on client side.

// Javascript
self.location.replace("url");

and you're rollinnnng
 
if you keep a flag variable in the client code and set it to some value on log-out, have your other pages checking that variable as they load - if the user has logged out (or never logged in) then just redirect them to some other page telling them they need to log in or whatever.
 
The Javascript code however require less coding and is replacing the history on the client side so no BACK needed.

However... a Flag could be useful as well as it will not be able to access page that he had not the prerequiste.

Your decision.
 
Back
Top