ASP.NET - how to logout programatically in

Asked By Sohel Shaikh on 27-Sep-12 11:29 AM
I have written following code for logout





"~/Default.aspx", true);

But when i click on browser's Back button my home page is again getting displayed so how to make sure that when the user click the back button after logout login page should get displayed
Robbe Morris replied to Sohel Shaikh on 27-Sep-12 03:02 PM
The browser is reading your page from the local cache on the user's desktop.  No trip to the server is being made.  You'll need to prevent the html from being cached locally to stop this behaviour.
Jitendra Faye replied to Sohel Shaikh on 01-Oct-12 01:40 AM
This is because of browser history, you have to clear history after logout,

for that, I provide you with solutions to disable back function in your web page as below:

1.Disable the page cache using script on server-side. The code is as below:

   Response.Buffer = true;
   Response.ExpiresAbsolute = DateTime.Now.AddHours(-1);
   Response.Expires = 0;
   Response.CacheControl = "no-cache";

2.Disable the page cache to let the browser no longer save cache of web pages on client-side as below:

    <meta http-equiv="Expires" CONTENT="0">  
    <meta http-equiv="Cache-Control" CONTENT="no-cache">  
    <meta http-equiv="Pragma" CONTENT="no-cache">  

3.Use javascript on client-side to realize the forward effect, this counteracts the action of user’s clicking back button. See the code below:

   <script type="text/javascript">  

try these and let me know.