Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anybody help me with log out?

I'm creating a web site in .net that has a log in and log out.
My problem is about log out.

When you click back in previous page I want to disable the back button.

How can I do that? :sigh:
Posted
Updated 9-Sep-10 0:06am
v2
Comments
Dalek Dave 9-Sep-10 6:06am    
Edited for Grammar and Syntax.

1 solution

Quite a common question answered number of times!

This happens because of cache.
1. clear the sessions
2. clear the cache such that browser has no history (this will make back/forward button in browser grayed out disabled.)
code for clearing cache can be put up in code behind as follows:
C#
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

You can add somethin similar in form aspx if you want to place it there:
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
 
Share this answer
 
v2
Comments
Dalek Dave 9-Sep-10 6:06am    
Good call.
JayantaChatterjee 19-May-13 8:50am    
My vote of 5!!!
Sandeep Mewara 30-May-13 6:30am    
Thanks.
Refer: http://www.codeproject.com/Tips/135121/Browser-back-button-issue-after-logout

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