We sometime face problem of back button that after logout then if we click back button then we able access those pages those already visited and that page always require login Session so if click on button go to login page.
Hereunder will give the code even if you click back button after logout you will remain in same page after you click back button.
If you click logout button go to login page and then click back button you will be same login page if you use this code.Use this code onclick of logout button.
this code is not working fully
not work properly. problem still remain...
I am unable to edit the code.Please use this code in Page_Init event..If your are using master page in then put this in master.aspx.cs file.
protected void Page_Init(object sender, EventArgs e)
Yes, Abhay Kumar Raut's post fix the issue. But the catch is, if the "Back" button is clicked, previous page URL is shown rather than "Log out" page URL.
you can check session varibale valu in master page
protected void Page_Load(object sender, EventArgs e)
if (Convert.ToString(Session["Username"]) != "")
One trick is here
1. Create one interstitial page say "LogOutInter.aspx"
2. write the logout code which is suggested in this article on logout button or link (not in interstitial page) and redirect to LogOutInter.aspx.
3. in LogOutInter.aspx load event check the urlreferrer if it is coming from the logoff button redirect to your home page or default page. else if it is coming from other pages redirect to same page which you got from urlreferrer.
So when you click to logoff you go to LogOutInter.aspx and from there some other page. When user clicks back button while is on some other page we will redirect to LogOutInter.aspx and from there again to some other page.
It's always a pleasure to hear from someone with expertise.
Check this below link.