Click here to Skip to main content
15,902,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hello
    How to prevent page nevigate to login page by clickon browser backbutton after login in website in asp.net  

 thank you 


What I have tried:

How to prevent page nevigate to login page by clickon browser backbutton after login in website in asp.net

thank you
Posted
Updated 2-May-16 23:43pm
v2

1 solution

You can't prevent the back key working in the browser - it pulls pages from it's internal cache so it will return to login pages.
However, you can set the Login page to uncacheable in the Page_Load event:
C#
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
and then check if your user is logged in. If he is, redirect him to your Home page (or another suitable one)
 
Share this answer
 
Comments
Kishor-KW 3-May-16 6:16am    
where should i put this code on home page or login page
OriginalGriff 3-May-16 6:33am    
Login page - that's the one you want to be uncached.

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