Click here to Skip to main content
13,588,580 members
Rate this:
Please Sign up or sign in to vote.
See more:
am having 2 webpages login.aspx,default.aspx are their in my web project,
after gave logout from default.aspx am redirecting to login page,back button of browser is pressed means it going to default.aspx , please tell me how to prevent it,it should be as login.aspx
Posted 3-Jan-13 23:43pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please have a look at my blog post on this subject[^]

This is because of caching on the browser and the way browser history works. The short answer to this question is

You don't disable the back button. The back button isn't yours to disable, it's part of my browser and I want it to work.

Usually when people post questions like this, it's because they don't understand how to control the flow of data from the site. In this case, the two things we are concerned with are authentication and caching.

So, add the caching directives to your pages and the user will be forced to reauthenticate before they can view your content again.
Aditya Magotra 4-Jan-13 6:04am

please tell me where to put this code in default.aspx or login.aspx
this code also


Dylan Morley 4-Jan-13 7:25am
Put it in your Page_Load event in default.aspx
Rate this: bad
Please Sign up or sign in to vote.

Solution 4


You can use Try and catch follow the below points it's very easy:

1.create sessions at the click of login button.
2. at the click of logout clear all sessions
3.when you clcik back button u ll navigate to the default page,to prevent this situation you need to use try and catch.

it ll help you if not let me know further.

Rate this: bad
Please Sign up or sign in to vote.

Solution 5

i think it helps you

<script type="text/javascript" language="javascript">
window.onkeydown = function(event)
if(event.keyCode == 8);
return false;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180615.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100