Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to remove history and cache after log out the application. I set the cache functionality off on page load. But after log out when i press back button then it will display webpage expired because of cache removed.

Can Anyone Tell me how to remove history on log out with asp.net.

Thanks,
Posted
Updated 5-Jul-12 21:50pm
v2

Have a look at this tip, it should help: Browser back button issue after logout[^]
 
Share this answer
 
Comments
Mohd Imran Saifi 5-Jul-12 1:30am    
i see this previously. but it will help me only clear the cache. but i also want to remove the browser history. cause when i doing back after logout it will display the web page is expired. but i do not want to display this msg.
Sandeep Mewara 5-Jul-12 2:24am    
Did you read/tried all? One of the options on the tip will disable the back button... not even letting user to click back.
bbirajdar 5-Jul-12 10:55am    
Sandeep.. I could not believe that the code running in the browser sandbox could disable the browser buttons. So I tried it myself.. The 'Back' button is not disabled using this code.. And AFAIK, it cannot be disabled ..

On the other hand, using the javascript, the page is moved forward in history on the click of back button such that the previous page from history is never displayed.
Sandeep Mewara 5-Jul-12 11:19am    
// Code disables caching by browser. Hence the back browser button grayed out (as if disabled)
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
bbirajdar 5-Jul-12 14:36pm    
I strongly disagree.. I tested it in IE 9 and it does not 'gray out'..Its still blue and can be clicked
Write these link to clear the session in the cs page.
C#
Session.Abandon();
        Session.Contents.RemoveAll();
        FormsAuthentication.SignOut();

and write in aspx page
HTML
<script type="text/javascript" >        history.forward();
    </script>


these code will clear all the session and browser history so that back button of the browser will not work.
 
Share this answer
 
v3
Comments
Mohd Imran Saifi 5-Jul-12 1:36am    
javascript will not help
bhagirathimfs 5-Jul-12 5:00am    
sorry didn't get your question.. :(
Mohd Imran Saifi 5-Jul-12 9:49am    
i mean :-
<script type="text/javascript" mode="hold" /> history.forward();
</script>
this code is not working.
bhagirathimfs 5-Jul-12 9:52am    
excluding that is your requirement fulfilled?
bhagirathimfs 5-Jul-12 9:54am    
Delete 'mode="hold" /'
Try This :-

XML
Begin the new script by entering in the following computer language code:

protected void logout()

{

This code tells the computer to initiate this code anytime the Web browser is closed.


Create the following code immediately under the code listed in Step 1:

session.abandon();

string nextpage="logout.aspx";

response.write (<script language=javascript>);


Type directly under the code provided in Step 3 the following language:

response.write (var backlen= history.length;);

response.write (window.location.href=' +nextpage+ ';);


Enter the code below to conclude the programming of your automatic history-clearing program:

response.write (</script>)

}
 
Share this answer
 
Comments
Mohd Imran Saifi 5-Jul-12 1:27am    
what's the purpose of: response.write (var backlen= history.length;);
it will simply save the history length in variable backlen. but there is now removal code for history.
Yatin chauhan 5-Jul-12 10:08am    
Its for to see that its content data in that or not. just for conformation to delete the history.

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