Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript MVC
I want to disable browser's back button after log out.
I have already set session["session-id"] to null on log out event.
But when I am pressing Back button of browser,it will redirect me to that secure page from which I've already log out.
Please Give me any solution about this problem.
Posted 25-Sep-12 20:15pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hey Bro.... try this out
I Perfectly got the solution.

When we request any page from server, browser maintains its cache in local system. When user press back button the cached page opened in front of user.
Its mean we have to disable the cache functionality for our session pages. So for this you have to insert this code into “Page_Load” event of the session page or to master page that is used for secure pages.
Response.Buffer= true;
Response.Expires =-1500;
Response.CacheControl = "no-cache";
if(Session["SessionId"] == null)
Response.Redirect ("WhereYouWantToGo.aspx");
This code just disable the cache for current page and save this page in buffer.
And buffer is maintained in memory so when user log
out the buffer will
destroy and no backup copy of that page available to view.
So its mean we successfully disable the back button.
Meet Raval at 26-Sep-12 2:23am
Thanks Hemant...
This works well in Internet Explorer.
But it is not working in Mozilla Firefox.
Plz tell me if you or anybody have solution about this issue...
Once again thanks hemant..
Have a nice day...
swaroopanalla at 24-Jul-13 6:40am
It works fine in firefox and chrome but not in IE
Developer Hemant Patel at 26-Sep-12 3:56am
sarathkumarnallathambi at 11-Jan-13 7:41am
Hi.. Its Not WOrking In Chrome...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Your Welcome Dude..
Try this out
add this line to your secure page
add this logout button
In my case it work in Mozilla..
Try it and review about this...
Meet Raval at 26-Sep-12 2:32am
Yes Hemant,
It's working well.
Thanks once again for giving me this solutions.
Genius Dude!!!!
Sandeep Mewara at 26-Sep-12 2:33am
You can either update your answer using 'Improve Solution' or use comment feature to respond to follow up questions of Op instead of posting a new answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Have a look at this Tip: Browser back button issue after logout[^]
Meet Raval at 26-Sep-12 2:43am
I've seen the link that you have given..
But it looks more complicated than previous solution.
Sandeep Mewara at 26-Sep-12 2:47am
It has multiple ways suggested. Strange to hear - it's complicated! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 528
1 OriginalGriff 459
2 ChintanShukla 305
3 Richard Deeming 275
4 RyanDev 230
0 Sergey Alexandrovich Kryukov 8,858
1 OriginalGriff 7,451
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893

Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100