Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a website in which first page is log in page and second page is home page.At first I enter into the home page by logging.Now if I click browser's back button log in page is loaded.Problem is that,if I click browser's forward button the home page is loaded.I want to disable the forward button such that the home page is not opened without
log in.Please give a solution with code.
Posted

Paste this code just before Page_Load event

Quote:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();


After that once you will leave Home Page by destroying session, you won't be able to go back to Home Page unless and until you log in

Please revert back to me in case of any doubts.

Thanks and regards
Suman Zalodiya.
 
Share this answer
 
I feel that you are going in wrong way.

for this you have to work with sessions. When the user login is validated successfully. you have to create a session, so that the session will be alive for the user. when the user want to go for log-out from the application the session will be closed.

So if any user access the home page directly. the session value is null. so that you can redirect to login page.

I think this is helpful to you.
 
Share this answer
 
I hav an answer for your query

It is done by javascript. Cut the below script into your page where u want to disable the back button of IE

<script language="JavaScript">
javascript:window.history.forward(1);
</script>


hope this will help u!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900