Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I want to redirect the user to login page when back button is clicked how to do it
Posted

Have a look here

Browser back button issue after logout[^]

You need to set your pages so that they aren't cached in the browser. If you have setup your site correctly with forms authentication & the user is now logged out, this will cause the page to redirect to the login page.
 
Share this answer
 
Comments
amolpatil2243 20-Jan-12 8:17am    
its great link, thank you for update us...
You can simply use Responce.Redirect("Page.aspx");

Hope this would work fine :))
 
Share this answer
 
Comments
Dylan Morley 20-Jan-12 7:50am    
No you can't - back button is client side and will display the cached page.
give hyperlink at back button

<a href="~/login.aspx">back</a>
 
Share this answer
 
Comments
Dylan Morley 20-Jan-12 7:53am    
The back button is *part of the browser* - you can't put a hyperlink there!
Put the following code on page load ....

C#
//Otherwise, all of our pages contain sensitive information, and we don't want them cached.
 Response.Cache.SetCacheability(HttpCacheability.NoCache);
 Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); //for Opera. May only work on https sites
 Response.Cache.SetNoStore();



if (Session.Count == 0)
 {

     Response.Redirect("login.aspx");

 }
 
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